|
-
Apr 17th, 2001, 03:23 PM
#1
Thread Starter
Hyperactive Member
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
Bababooey
Tatatoothy
Mamamonkey
-
Apr 17th, 2001, 07:02 PM
#2
Frenzied Member
Code:
char input[256];
cin.getline (input,256);
-
Apr 17th, 2001, 09:27 PM
#3
Thread Starter
Hyperactive Member
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
Bababooey
Tatatoothy
Mamamonkey
-
Apr 17th, 2001, 11:13 PM
#4
Lively Member
i for one am confused. could you explain a little more.
-
Apr 18th, 2001, 07:00 AM
#5
Thread Starter
Hyperactive Member
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,
Bababooey
Tatatoothy
Mamamonkey
-
Apr 18th, 2001, 08:37 AM
#6
Frenzied Member
You are not clear. Post the declaration for szInput, what is szInput, what kind of a variable. Is it a string <string> library, char ...
-
Apr 18th, 2001, 12:07 PM
#7
Lively Member
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;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|