I recently started learning C++ off the tutorials on this site and they are great. I've started making my own simple program which takes in information and trying to make it display it in a structured format. I first used int name, and int alias. When i ran the program it would work fine but when it came to cin>>name; and cin>>alias; it would close the program because the user was inputting letters and instead of numbers. So i changed some stuff around and this is what i have so far.
char name, alias, filename;
cout<<"Please enter your real name: ";
cin.getline(name, 50, '\n');
cout<<"Please enter your age: ";
cout<<"How long have you been playing in years: ";
cout<<"Whats your in-game name: ";
cin.getline(alias, 50, '\n');
//Gets In-Game Name
cout<<"This is all the info you have entered"<<endl;
//Displays information inputted from user
cout<<"Is this information correct? Press 1(Yes) or 2(No) then enter: ";
cout<<"Please enter a 1-word name for the info to be saved in: ";
cin.getline(filename, 50, '\n');
cout<<"Cannot save file "<<filename<<endl;
//Added the "Cannot save file" msg to inform user it cant do anything yet
cout<<"Please restart program";
//Loop function not implemented yet
Excuse the untidyness. I compile and build the program just fine. But when i run it (via msdos) it takes in name part, then the age, years playing... and then "skips" the ALIAS part and goes right into the "do you want to save" part, if i pick yes it "skips" the filename part and closes the program.
Could someone tell me why is it doing this? And if possible explain it in a way a beginner would understand.
Thanks for taking the time to read this!