Hello all. I just started trying to learn how to program and I have been studying the tutorials here and reading C++ Programming in easy steps by Mike McGrath. I have the first three lessons down pretty well, but I get in over my head about halfway through Functions. So I went back to Lesson 2: If Statements and tried to write my own little program for my out-of-town gf.
I get these errors:Code:#include <iostream> using namespace std; int main () { int name; cout<<"Please give your full name. Don't forget your capitalization.: "; cin>> name; cin.ignore(); if ( name == Jennifer ***** ******** ) { cout<<"Hello love.\n"; } else { cout<<"Hey! What have you done with my girlfriend?!\n"; } cin.get(); }
`Jennifer' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
If I change this line
To thisCode:if ( name == Jennifer ***** ******** ) {
I get this errorCode:if ( name == "Jennifer ***** ********" ) {
ISO C++ forbids comparison between pointer and integer
This is what I was using as a reference
I took out the else..if because in my case it is either right or wrong, and I really don't know what else to try. I know this is extremely basic but I am having trouble grasping any of it.Code:#include <iostream> using namespace std; int main() // Most important part of the program! { int age; // Need a variable... cout<<"Please input your age: "; // Asks for age cin>> age; // The input is put in age cin.ignore(); // Throw away enter if ( age < 100 ) { // If the age is less than 100 cout<<"You are pretty young!\n"; // Just to show you it works... } else if ( age == 100 ) { // I use else just to show an example cout<<"You are old\n"; // Just to show you it works... } else { cout<<"You are really old\n"; // Executed if no other statement is } cin.get(); }
Thanks for any help.



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.