c 文件操作 如下代码 //标记的地方作用何在?求解答
#include<stdio.h>#include<stdlib.h>
void main()
{
FILE *fp;
char ch, filename;
printf("Please enter filename!:");
scanf("%s", filename);
if( !(fp = fopen(filename, "wb+")) )
{
printf("Cannot open the file!");
exit(0);
}
printf("please enter some sentences!:");
ch = getchar(); //用两个ch = getchar 作用何在?求解答!
ch = getchar();
while( ch != EOF )
{
fputc( ch, fp );
ch = getchar();
}
fclose(fp);
} 清除一下缓冲区的那个‘\n’ 哥斯拉不说话 发表于 2015-8-7 11:56
清除一下缓冲区的那个‘\n’
谢谢!
页:
[1]