Yesterday I started with c++, everything went well with a few good tutorials but right now I can't go on! I have a problem I can't fix! Made a little talking programm...
Here is the code:
And these are the errors:Code:// cin with strings #include <iostream> #include <string> using namespace std; int main () { string mystr; cout << "Let's have a chat!\n"; cout << "What's your name?\n"; getline (cin, mystr); cout << "Hello " << mystr << ".\n"; cout << "How old are you?\n"; getline (cin, mystr); cout << "So you are " << mystr << " years old?\n"; cout << "Whats the name of the town where you live in?\n"; getline (cin, mystr); cout << "In which country can I find " << mystr << " ?\n"; getline (cin, mystr); cout << "Ah I see, I never in " << mystr << " but I would like to!\n"; cout << "This little programm is made in c++, do you use c++ to?"; getline (cin, mystr); if (mystr == yes) { cout << "Well, that's great, than you should know how this programm works!"; } else if (mystr == no) { cout << "I can recommend you to learn c++, it's really great!"; } return 0; }
#####\visual studio 2005\projects\talkingwithpc\talkingwithpc\source1. cpp(23) : error C2065: 'yes' : undeclared identifier
#####\visual studio 2005\projects\talkingwithpc\talkingwithpc\source1. cpp(27) : error C2181: illegal else without matching if
#####\visual studio 2005\projects\talkingwithpc\talkingwithpc\source1. cpp(27) : error C2065: 'no' : undeclared identifier
Many thanks to the ones who take a look at this topic, and more to the ones who make me solving my problem.![]()
BTW: Mery chrismas and a happy new year!



LinkBack URL
About LinkBacks



