Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

File input/output operation

nivp4mnivp4m Posts: 14Member
I have created a program in which i enter some data in file named "input" and then i close that file and again open that file to display the contents which was previously stored...
but the problem is when i run that program it goes on taking the data without any halt plz help me to sort out my problem.


#include
#include
main()
{
FILE *f1;
char c;
printf("Data input output");
f1=fopen("Input","w"); /*Open the file Input*/
while((c=getchar())!=EOF) /*get a character from key board*/
putc(c,f1); /*write a character to input*/
fclose(f1); /*close the file input*/
printf("
Data output
");
f1=fopen("INPUT","r"); /*Reopen the file input*/
while((c=getc(f1))!=EOF)
printf("%c",c);
fclose(f1);
}

Comments

Sign In or Register to comment.