By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Reading Strings

P: 51
Hi!!!!!!!, I want to read two strings that the user must enter, and i am doing it this way:

cout << "Please enter the text that you want to Encrypt (128 bits legth)" << endl;
getline (cin, a);

length1 = a.size();

cout << "Please enter the key to Encrypt the text (128 bits legth and Hex format)" << endl;
getline (cin, b);
length2 = b.size();

and I have a problem, because I don't why this program does not read the second one, could you please tell me how can I read the two strings (the problem is that the instruction getline (cin, b);, does not execute). Thank you
Sep 15 '06 #1
Share this Question
Share on Google+
2 Replies

P: 51
I need help. . . . . . . . . .
Sep 17 '06 #2

P: 293
I think it may be because the only thing left in the buffer is the return character "\n". Either you can flush the buffer (I am not sure how) or empty it by calling getline(cin,b) once, then calling getline(cin,b) again to actually get data.
Sep 18 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.