I have just started to learn C++ and find it very fun. I know VB very well and know a bit of Pascal. I was writing my first program and this is all the code.
The program is VERY simple and it is meant to ask for your name and age and then say it back to you. When it starts is says this:Code:#include <iostream.h> #include <stdlib.h> using namespace std; int main() { cout<<"Hello\n"; cout<<"Please enter your name\n"; int name; cin>> name; cin.ignore(); cout<<"Now enter your age\n"; int age; cin>> age; cin.ignore(); cout<<"So you are called"<< name <<"and you are"<< age <<"years old\n"; cin.get(); }
Hello
Please enter your name
I enter my name and press enter but instead of asking me how old I am it ends the program. I searched the forum and found a thread that said to add cin.ignore(); so that the enter was ignored. I added this but the same thig happens. Debbuging finds nothing and I don't know how to fix it.
Any help would be goo
Thanks
Calum N![]()



LinkBack URL
About LinkBacks



