글쓴이: 익명 사용자 / 작성시간: 토, 2001/12/08 - 5:53오후
#include
main()
{
char c;
FILE *fi;
fi=fopen("temp.txt", "w");
while((c=getchar())!=EOF)
fputc(c, fi);
fclose(fi);
}
실행결과
문자를 입력하고 CTRL+z키 누르면 빠져나옵니다. temp.txt파일도 생성되어있는데 입력한 문자가 없다는 것입니다. 즉,
temp.txt의 크기가 0byte 입니다. 뭐가 잘못된건지요?
Re: fopen 함수 예제 질문
제가 보기에는
signal 처리를 하지 안았으니 빠져 나갈수 밖에 없구요.
그리고 EOF 는 ctrl+D 니까
다 쓰시고 ctrl+D를 누르면
내용이 저장 되어 있을거에요..
Re^2: fopen 함수 예제 질문
일호 wrote..
제가 보기에는
signal 처리를 하지 안았으니 빠져 나갈수 밖에 없구요.
그리고 EOF 는 ctrl+D 니까
다 쓰시고 ctrl+D를 누르면
내용이 저장 되어 있을거에요..
감사합니다. ctrl+D 였군요.
그런데 signal 처리가 무슨 뜻이죠? 초보라서 무슨 뜻인지 모르겠어요. ㅤ_ㅤ
Re^3: fopen 함수 예제 질문
Ctrl+Z 를 누르면 실행되는 프로세스에 STOP signal이 전송됩니다.
프로세스는 특별히 signal 처리를 해주지 않으면 signal이 들어옴과 동시에
interrupt 되어서 실행이 중지되어 버립니다.
댓글 달기