【发布时间】:2020-09-13 08:32:53
【问题描述】:
为什么我们在while循环中使用getchar()函数在写模式中接收值,为什么getch或getche函数不能用过吗?
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
FILE *f;
char r;
f=fopen("muster_up.txt","w");
while((r=getchar())!=EOF)
{
fputc(r,f);
}
fclose(f);
f=fopen("muster_up.txt","r");
while((r=fgetc(f))!=EOF)
{
printf("%c",r);
}
fclose(f);
getch();
}
【问题讨论】:
标签: c