fcloseall
원형
int fcloseall(void);
헤더 파일
stdio.h
기능
열려져 있는 모든 스트림을 페쇄한다.
단 stdin, stdout, stdpin, stderr, stdaux등의 기정의 스트림은 폐쇄하지 않는다
리턴값
닫혀진 스트림의 총 수를 리턴하고 에러가 발생한 경우에 EOF(-1)을 리턴한다
참고함수
fclose() => 특정 스트림만 폐쇄
fopen, fflush
// -------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char buffer[80];
FILE *stream;
FILE *stream2;
printf("\n============= AUTOEXEC.BAT ===========\n\n");
stream = fopen("c:\\autoexec.bat","rt");
if(stream == NULL)
{
printf("File open error\n");
exit(1);
}
while(!feof(stream))
{
if(fgets(buffer,80,stream)==NULL)
{
break;
}
printf("%s",buffer);
}
printf("\n============= CONFIG.SYS ===========\n\n");
stream2 = fopen("c:\\config.sys", "rt");
if(stream2 == NULL)
{
printf("File open error\n");]
exit(1);
}
while(!feof(stream2))
{
if(fgets(buffer,80,stream2)==NULL)
{
break;
}
printf("%s",buffer);
}
fcloseall(); // 모두 닫게 한다.
return 0;
}
원형
int fcloseall(void);
헤더 파일
stdio.h
기능
열려져 있는 모든 스트림을 페쇄한다.
단 stdin, stdout, stdpin, stderr, stdaux등의 기정의 스트림은 폐쇄하지 않는다
리턴값
닫혀진 스트림의 총 수를 리턴하고 에러가 발생한 경우에 EOF(-1)을 리턴한다
참고함수
fclose() => 특정 스트림만 폐쇄
fopen, fflush
// -------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char buffer[80];
FILE *stream;
FILE *stream2;
printf("\n============= AUTOEXEC.BAT ===========\n\n");
stream = fopen("c:\\autoexec.bat","rt");
if(stream == NULL)
{
printf("File open error\n");
exit(1);
}
while(!feof(stream))
{
if(fgets(buffer,80,stream)==NULL)
{
break;
}
printf("%s",buffer);
}
printf("\n============= CONFIG.SYS ===========\n\n");
stream2 = fopen("c:\\config.sys", "rt");
if(stream2 == NULL)
{
printf("File open error\n");]
exit(1);
}
while(!feof(stream2))
{
if(fgets(buffer,80,stream2)==NULL)
{
break;
}
printf("%s",buffer);
}
fcloseall(); // 모두 닫게 한다.
return 0;
}
'Native > C' 카테고리의 다른 글
29page 예제 1-8 (0) | 2013.10.02 |
---|---|
[레퍼런스] fcvt() (0) | 2013.10.02 |
[레퍼런스] fclose() (0) | 2013.10.02 |
[레퍼런스] difftime() (0) | 2013.10.02 |
[레퍼런스] creattemp() (0) | 2013.10.02 |