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
Post a Comment