Hi i have the following code
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <conio.h>
int main()
{
FILE *fp;
char c=' ';
fp=fopen("E:\data.txt","w");
if(fp==NULL)
{
printf("Cannot open file");
exit(1);
}
printf("Write data & to stop press '.' :");
while(c!='.')
{
c=getche();
fputc(c,fp);
}
fclose(fp);
printf("\nContents Read:");
fp=fopen("E:\data.txt","r");
while(!feof(fp));
printf("%c",getc(fp));
}
And when executing the above code , i have the following output
Output:
Write data & to stop press '.' :writing data into the file.
Contents Read:
Output doesn't display the contents which i have inputted.
Please help me where did i went wrong.