james00harper
Programmer
When using the c++ cin.getline function you can use an overloaded version that allows you to enter input the name of the string where the input stream will be copied to, the size of the string and the delimiting character. Eg cin.getline(Buffer,20,'\n');
Function works fine for less than 20 character. As expected when you input more than 20 characters only the first 20 characters are copied to Buffer. However the remaining characters of the stream after the 20th character are held in an input buffer. When ever you want to use cin.getline again the buffered characters are dumped on screen not allowing you to use the function unless its called again.
How do you flush the input buffer. Have already tried cin.clear, cout.flush and loads of other things.
Any advice - its a bit of a mouth full, but I'm pulling my hair out about it.
Function works fine for less than 20 character. As expected when you input more than 20 characters only the first 20 characters are copied to Buffer. However the remaining characters of the stream after the 20th character are held in an input buffer. When ever you want to use cin.getline again the buffered characters are dumped on screen not allowing you to use the function unless its called again.
How do you flush the input buffer. Have already tried cin.clear, cout.flush and loads of other things.
Any advice - its a bit of a mouth full, but I'm pulling my hair out about it.