把从键盘输入的文本按原样输出到名为file_a.txt的文件中,用字符@作为键盘输入结束的标志

源程序:

//把从键盘输入的文本按原样输出到名为file_a.txt的文件中,用字符@作为键盘输入
//结束的标志
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fpout;
char ch;
if((fpout=fopen("e:\\file_a.txt","w"))==NULL)
{
printf("can't open this file!\n");
exit(0);
}
ch=getchar();
while(ch!='@')
{
fputc(ch,fpout);
ch=getchar();
}
fclose(fpout);
return 1;
}

 运行结果:

猜你喜欢

转载自www.cnblogs.com/duanqibo/p/12033350.html
今日推荐