Thursday 25 February 2016

Create a file and store data in it in c program

#include<stdio.h>
 int 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);
 return 0;
 } 

No comments:

Post a Comment