Read my previous post's edit.
Ok, it works pretty well, but there's one thing thats bugging me. After every definition, it says the cout in my else statement.
Make sure you have all your definitions in else if statementsQuote:
Originally Posted by pandapwnage
jmd15, I wasnt refering to your coding abilities by saying "what kind of C++ Programmer are you". I said that because you posted C when your title says C++ :p What I said after that wasn't meant to continue from that as criticism, just pointing out so the OP knows, yah know.
Just a note that the way this program is setup it wont be able to handle more than this simple program, and just so you know for later projects.. using a while statement would also work here, instead of goto, like so:
Thats usually how its done.Code:
cout<<"Enter a name: ";
if ( strcmp(name,"Shayne")==0 )
cout<<"Shayne is a twenty fifth dinosaur pagent.\n";
else if ( strcmp(name,"Jamie")==0 )
cout<<".... and so on and so on for like 10 names..\n";
Yes, that is also a good way to do it. Probably even a better way. Just a note, in your if statements(this includes else if, and else) you use brackets around the code to be executed if that condition is true. UNLESS you only have one line of code to be executed then you don't need brackets, but maybe is a good idea just to get into the habit so you don't forget them.
Sorry for getting angry, I interpreted your comment in the wrong way.
strcmp is in <cstring>, not <string>.
You should use Dae's first version that uses the C++ string class (with one change: add #include <string>). It is easier and safer to use than the C-style character arrays in jmd15's examples.