programming-examples/c/Data_Input_Output/C program to open a file and store data in it.c

11 lines
226 B
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
#include<stdio.h>
void main()
{
FILE *fp;
char ch;
fp=fopen("file.txt","w");
printf("\nEnter data to be stored in to the file: ");
while((ch=getchar())!=EOF)
putc(ch,fp);
fclose(fp);
}