Hey guys -
I'm a c++ n00b, but I'm slowly starting to get the hang of it. For a bonus assignment in class, we have to make a little survey type application, and then the output just restates what the user put in (I guess to show we know how to I/O).
I'm having trouble with the address and college major inputs. Because they both most likely will have spaces in whatever the user inputs, it's messing me all up!Please take a look at my code and tell me what I'm doing wrong!
Code:// Personal Survey // Jennifer Tonon // 10-12-05 // This progam stores personal information entered by a user, and repeats // it back to them for confirmation. #include <iostream> #include <string> using namespace std; int main() { char cName [15]; // user's first name char cLast [15]; // user's last name string cAddress; // user's street address char cCity [20]; // user's city char cState [15]; // user's state char cZip [5]; // user's zip code char cTelephone [10]; // user's telephone number string cMajor; // user's college major cout << "What is your first name? "; cin >> cName; cout << "What is your last name? "; cin >> cLast; cout << "What is your street address? "; getline(cin,cAddress,'\n'); cout << "What is your city? "; cin >> cCity; cout << "What is your state? "; cin >> cState; cout << "What is your zip code? "; cin >> cZip; cout << "What is your telephone number? "; cin >> cTelephone; cout << "What is your major in college? "; getline(cin,cMajor,'\n'); cout <<"Your first name is " << cName <<"\n"; cout <<"Your last name is " << cLast <<"\n"; cout <<"Your street address is " << cAddress << "\n"; cout <<"Your city is "<< cCity <<"\n"; cout <<"Your state is " << cState <<"\n"; cout <<"Your zip code is " << cZip << "\n"; cout <<"Your telephone number is " << cTelephone << "\n"; cout <<"Your major is " << cMajor << "\n"; system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks
Please take a look at my code and tell me what I'm doing wrong!


