文件的打开与关闭
请教大家:谭浩强c程序设计中文件一章中
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *fp;
char ch, filename[10];
scanf("%s", filename);
if ((fp = fopen(filename, "w")) == NULL)
{
printf("cannot open file");
exit(0);
}
ch = getchar();
ch = getchar();
while (ch != '#');
{
fputc(ch, fp);
putchar(ch);
ch = getchar();
}
putchar(10);
fclose(fp);
}
我运行时输入file2.c[回车]
computer and c#[回车]
却没有结果是怎么回事?
请求!!