分类:
2008-10-13 16:30:22
选自周星星的blog
#include
int main( void )
{
FILE* fp = fopen( "D:\\test.txt", "r+" ); // 文件内容:12345
char c;
fread( &c, 1, 1, fp ); // 函数返回1,c为'1' --- 也就是一切正确
// fseek(fp,0,SEEK_CUR); --- []和[]说加上这一句就好了
fwrite( "a", 1, 1, fp ); // 函数返回1 --- 也就是一切正确
fclose( fp ); // 函数返回0 --- 也就是一切正确,然而文件内容仍然为 12345 而没有变为 1a345
return 0;
}
答:ouput cannot be directly followed by input without an intervening fflush, fseek, fsetpos, or rewind.
Input cannot be directly followed by output without an intervening fseek, fsetpos, or rewind, or an input operation that encounters an end of file.