my code
the following partCode:#include<iostream> #include<cstring> using namespace std; int main() { int x; x=1; int choice; int usenr; usenr=001; char usename[20]; char comment[250]; int age; char pwd[10]; while(x==1) { cout<<endl; cout<<"This program demonstrates all functions i worked with up to now!\n"; cout<<"These include... \n IF...ELSE \n LOOPS \n FUNCTIONS \n SWITCH CASE \n POINTERS \n STRINGS \n"; cout<<"PLease select from the following...\n"; cout<<" 1.EDIT PROFILE \n 2.VIEW PROFILE \n"; cout<<" 3.EXIT \n"; cin>>choice; switch(choice) { case 1: cout<<"To chnge your profile you need to enter your password.\n Please enter your password now \n"; cin.getline(pwd,10); if(strcmp(pwd,"rhino")==0) { cout<<"Admin access granted!\n"; cout<<"Please enter your name: \n"; cin.getline(usename,20); cout<<"Please enter your age: \n"; cin>>age; cout<<"Tell us a little bout yourself(max 250 characters):\n"; cin.getline(comment,250); } else { cout<<"Sorry, wrong password!\n"; } break; case 2: cout<<"Welcome "<<usename<<" This is your profile:\n"; cout<<"User Number: "<<usenr<<"\n"; cout<<"User name: "<<usename<<"\n"; cout<<"User age: "<<age<<"\n"; cout<<"Your comment is: "<<comment<<"\n"; cout<<"Please make sure this is correct and press enter\n"; cin.get(); break; case 3: cout<<"Are you sure?\n"; break; default: cout<<"Sorry, incorrect input\n"; break; } cout<<"Thank you for your participation! \n To try again press 1. \n or else press any key to exit\n"; cin>>x; } cin.get(); }
why is this? what am i missing?Code:cin.getline(pwd,10)



LinkBack URL
About LinkBacks


