我是新来的文件处理,当我试图从键盘读取文件的数据并输出该文件的内容在屏幕上我没有得到所需的结果与下面的代码文件处理在c不产生所需的结果
/* get data from the keyboared till the end of file and write it to the
file named "input" agian read the data from this file on to the screen*/
#include <stdio.h>
int main()
{
FILE *fp;
char c;
printf("enter the data from the keyboared\n");
fp=fopen("input.txt","w");
while((c=getchar()!=EOF))
{
putc(c,fp);
}
fclose(fp);
printf("reading the data from the file named input\n");
fopen("input.txt","r");
while((c=getc(fp))!=EOF)
{
printf("%c",c);
}
fclose(fp);
return 0;
}
我得到的输出是这样的h?
还有一种方法,以便我可以找出在硬盘上创建该文件的位置?
什么问题/错误? – m0skit0 2012-02-07 12:51:08
虽然我们自己尝试并不困难,但如果您正在讨论意外/不想要的结果,通常会发布您期望的结果和取而代之的结果。 – Bart 2012-02-07 12:51:15