Hi I'm learning C++ on my own here and am experiencing a problem with an introductory program I've created.
My book provided me with a bit of code near the end to prevent my program from closing on me immediately, however it is closing on me as soon as I finish entering my first name (first cin):
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
char name;
int age;
char favoritecolor;
cout << "Please enter your name: " << endl;
cin >> name;
cout << "Please enter your age: " << endl;
cin >> age;
cout << "Please enter your favorite color: " << endl;
cin >> favoritecolor;
cout << name << age << favoritecolor << endl;
cout << "CCCCCCCCC ++ ++ " << endl;
cout << "CC ++ ++ " << endl;
cout << "CC ++++++++++++++ ++++++++++++++" << endl;
cout << "CC ++++++++++++++ ++++++++++++++" << endl;
cout << "CC ++ ++ " << endl;
cout << "CCCCCCCCC ++ ++ " << endl;
// The following 6 lines of code delays termination of the program until
// the user presses the enter key. This is a convenience for those using
// a windows environment but it will work on every platform.
char any_keystroke;
//reads and ignores up to 200 characters, or '\n' is read and ignored
cin.ignore(200, '\n');
cout << "\n\n";
cout << "Program execution has ended normally.\n";
cout << "Press the enter key to exit.";
cin.get(any_keystroke);
return 0;
}