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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -