This program takes the first entry(admno and name) perfectly but but skips admno if I want to input another entry.
Compiler used - Codeblocks
Maybe the problem lies with getline.
Any suggestions ?
I myself would guess the problem has to do with that cin >> ch. Remember this leaves the end of line character in the stream which messes with getline().
Then what do you recommend about it ?
Because cin.ignore is not working at all times.
Even after using it, if for eg. I enter admno=6035 first time, the second entry for admno in the file "student.txt" is 035 irrespective of what I enter.
After adding ignore after cin>>ch, the program does not take the first entry's admno. i.e. it skips admno and directly asks for name.
After that it works without any problem.
Why is this happening ?