キーパッドからファイルにデータを読み込み、そのファイルの内容を画面に出力しようとしたときにファイル操作が新しくなりました。以下のコードで希望の結果が得られません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;
}
私はこのような出力を得ていますか?
また、このファイルがハードディスク上のどこに作成されているかを知る方法はありますか?
問題/エラーは何ですか? – m0skit0
予期せぬ/望ましくない結果について話しているのなら、自分自身で試してみるのは難しいことではありませんが、あなたが期待しているものと受け取ったものを投稿するのが通常は便利です。 – Bart