Bhuvan InfoTech Android App

Download our Android App and browse Technical News, Projects, Computer Tricks more easily with lots of Interesting Features.

Tuesday, June 14, 2016

Write to text file | file handling | C Program

#include <stdio.h>
#include <stdlib.h>
int main()
{
   char sent[1000];
   FILE *fp;

   fp = fopen("program.txt", "w");
   if(fp == NULL)
   {
      printf("Error!");
      exit(1);
   }
 
   printf("Please Enter a string:\n");
   gets(sent);

   fprintf(fp,"%s", sent);
   fclose(fp);

   return 0;
}
Bhuvan Arora

No comments:

Amazing Deal !