文件输入操作putc怎样结束
ningv 2011-05-17 09:46:09 刚刚学习C的文件管理。用putc接收字符后不知怎么结束,书上的案例是输入“^Z”后就结束了,但我却不行。以下代码是照搬书上的。
#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
main()
{
FILE *f1;
char c;
printf("Data Input\n\n");
f1=fopen("INPUT","w");
while((c=getchar()) !=EOF)
putc(c,f1);
fclose(f1);
printf("\nData Output\n\n");
f1=fopen("INPUT","r");
while((c=getchar()) !=EOF)
printf("%c",c);
fclose(f1);
}