c - How to add multiple lines in text file -


i trying write program can display contents of file append content dynamically user text file in c.

below code, somehow working single line input , not multi-line input in loop.

fobj=fopen("test3.txt","a"); if (fobj==null)  {   printf("error opening file.  ");   exit(0);   } int contd; char buff1[120]; char *chptr; { printf("enter line : \n");  gets(buff1);  fputs(buff1,fobj);  printf("enter continuation code : "); scanf("%d",&contd);  }while(contd!=0); 

you facing typical stdin issue. can use fflush(stdin); before gets, should work.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -