首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

C99里面没有fcloseall这个函数?解决方案

2013-11-18 
C99里面没有fcloseall这个函数?#include stdio.h#include stdlib.hint main(int argc,char * argv[]){

C99里面没有fcloseall这个函数?
#include <stdio.h>
#include <stdlib.h>

int main(int argc,char * argv[])
{
FILE* fp1,*fp2;
if((fp1=fopen("file1.txt","w"))==NULL)
{
printf("Open file1.txt is failed\n");
}


printf("Open file1 is successful\n");



if((fp2=fopen("file2.txt","w"))==NULL)
{
printf("Open file file2.txt failed\n");
}

printf("Open file2.txt is successful\n");


if(fcloseall()==EOF)  
{
printf("Close all files is failed\n");

}

else{
printf("Close all files is successful\n");
}

return 0;



return 0;
}

编译运行之后,出现: 
warning: implicit declaration of function 'fcloseall' is invalid
      in C99 [-Wimplicit-function-declaration]

1 warning generated.
Undefined symbols for architecture x86_64:
  "_fcloseall", referenced from:
      _main in ex4-2-qa5bvV.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

是不是说,在C99里面没有fcloseall这个函数?

[解决办法]
FCLOSE
Section: Linux Programmer's Manual (3 )
Updated: 1998-04-10 
--------------------------------------------------------------------------------
  
NAME
fcloseall - close all open streams   
SYNOPSIS
#define _GNU_SOURCE 
#include <stdio.h> 

int fcloseall(void);   

DESCRIPTION
The fcloseall function dissociates all open streams from its underlying file or set of functions. Any buffered output data is written first, using fflush(3). Note that the standard streams (stdin, stdout and stderr) are also closed.   
RETURN VALUE
This function always returns 0.   
SEE ALSO
close(2), fclose(3), fflush(3), fopen(3), setbuf(3)   
CONFORMING TO
The fcloseall function is a GNU extension. 
--------------------------------------------------------------------------------

热点排行