fgets() and fputs() functions In C Language
fgets() function reads string from a file pointed by file pointer. It also copies the string to a memory location referred by an array.  
fputs() function is useful when we want to write a string into the opened file .
  Program : The following program is an example of fgets() and fputs()
#include
main()
{
FILE *fp; 
char file[12],text[50]; 
int i=0;
fp = fopen(“line.txt” ,”w”); 
printf(“Enter text here : “); 
scanf(“%s”, text); 
fputs(text, fp ); 
fclose(fp); 
fp = fopen(“line.txt”, “r”); 
if(fgets(text,50,fp )!=NULL)
while(text[i]!='\0') 
{ 
 putchar(text[i]);
  i++; 
} 
fclose(fp ); 
getch();  
}
Output :

Enter text here : FreeTimeLearn
FreeTimeLearn