A C program to write to file and display it
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *f1;
char c;
clrscr();
printf("Enter content to File\n");
f1=fopen("first.dat","w");
while((c=getchar())!=EOF)
{
putc(c,f1);
}
fclose(f1); printf("The stores data\n\n");
f1=fopen("first.dat","r");
while((c=getc(f1))!=EOF)
{
printf("%c",c);
}
fclose(f1);
getch();
}
|