Ok so im really new at this. Im taking a college class and we are learning c++ right now. Im writing a code and i have run into a snag and i have searched the internet and books for hours trying to solve it and i still cant do it. So if anyone can help it would very much be appreciated.
So basically i ask a user for their name, thier FULL name. When i run the code it asks me to enter the name. Now when i enter the first name such as "Johnny" it moves on through the code right nice. Now if i were to enter "Johnny Doe" it skips over my next statement and goes right to the next one after that. Like i said any advice will help. I will give any other information you would need about my code to help sovle it. THANKS!
If you are using the plain-vanilla <string> getline() to get the string, you have got the entire name. What do you do with the string after you get it?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string users_full_name;
cout << "Please enter your full name> ";
getline( cin, users_full_name );
cout << "Hello " << users_full_name << ", you good-looking person you!\n";
return 0;
}
yeah i tried that and its still not working... It gets cout later on, nothing fancy. Is there a way that i dont have to use string? Is there a way to do it as a cin.getline? Now when i run my code it doesnt allow me to enter the first value but i can enter the rest of them.
ok i figured it out. I needed to use the cin.ignore() operator. I have however haha another issue. This one is really weird. So it asks the user how they think their results will turn out. They could put stuff like"good, great, fine, etc." Well whatever they put in the first letter gets cut of when it goes through cout. So if they put in "good" the result is "ood." this one is really throwing me for a loop. This is all i have to fix on this code and it will be complete. Any tips? Thanks