I'm having trouble with a section of the code I am using to get a few words from the user, put them into a buffer, then send that buffer to a string. Not even sure it will work, since it will include whitespace in a string, but I'm trying
The problem is this: the cout<< line hits, tells me to input a couple of words, then immediately, without getting input from me, moves to the next line, then continues on, completely skipping the cin.getline(). Am I doing something wrong?
the pause is just there because my prompt window closes automatically at program termination. The cout<< statements are just there to validate what is going in and out of those variables for now. Right now, it does NOTHING. no input, no output. Which makes sense... but why does the code just run right over the getline without running it?Code:char tester; cout<<"enter a couple words: \n"; cin.getline (tester, 26); test = tester; cout<<tester; cout<<test; system("PAUSE");
If it helps any, I am using bloodshed dev C++ 220.127.116.11, on windows XP.
I have ran another program using getline, on this computer, and it works just fine. Tried copying and pasting, too, then changing the variable names... no luck. it skips it. sooooo... help?
EDIT: For whatever reason, putting the getline code in TWICE makes it work once. They are identical copies of each other. So, I am beginning to think compiler problem, and debating a reinstall.
Further update... removing it from that section of the code, moving it higher in the program, and re=pasting it fixed it... I'm still looking for WHY though!
Anyone have any other ideas before I go to that?