Skip to main content

C program to write strings in existing file using fputs()


#include<stdio.h>
#include<string.h>
#include<conio.h>
 void main()
 {
   char s[50];
   FILE *pk=fopen("keviv.txt","w++");
   clrscr();
   if(pk==NULL)
   { printf("\n FILE DOES NOT EXIST ");
     getch();
     exit(0);
   }

   while(1)
   { gets(s);
     if(strlen(s)==NULL)
       break;
     fputs(s,pk);
   }

   fclose(pk);
 }

Comments