-
how come when i use getline in the following form:
Code:
getline(cin,szInput,'\n');
i have to press enter twice, once for the getline function
to stop and one to return to the next line....
i want it so that i press it once, it ends the function and
returns to the next line
anyone have any ideas?
thx in advance
-
Code:
char input[256];
cin.getline (input,256);
-
can't use that, i have to store the line input in a string and i get errors when i try to use one
getline(cin,szName,'\n') is what i'm inquring about
-
i for one am confused. could you explain a little more.
-
ok, i ask for a string, the user inputs it. After the user enters the string, he/she should only have to press return once, however, you have to press it twice for it to 'step' to the next part of the code. the console will go down another line after you hit return which is NOT what i want. i want hte user to input the string, they press return, and the next piece of code is followed, as oppposed to what is happening now, having to press return twice,
-
You are not clear. Post the declaration for szInput, what is szInput, what kind of a variable. Is it a string <string> library, char ...
-
Code:
#include <iostream>
#include <string>
int main()
{
std::string input;
std::cout << "Enter string:";
std::getline(std::cin, input);
std::cout << input << std::endl;
return 0;
}