   [c++] help please input error
  hi guys i need help i was wondering why this code doesn't workbasically after entering the name it doesn't accept any input from that point on and just goes straight to termination.#include &lt;iostream&gt;using namespace std;int main(){char quit_choice;do {int choice;char name;cout &lt;&lt; " to start this adventure please type in your name ";cin &gt;&gt; name;cout &lt;&lt; endl;cout &lt;&lt; " hello " &lt;&lt; name;cout &lt;&lt; " you are a warrior and a boar attacks you ";cout &lt;&lt; endl &lt;&lt; " what do you do? " &lt;&lt; endl&lt;&lt; " 1) accurate lunge" &lt;&lt; endl&lt;&lt; " 2) crushing blow" &lt;&lt; endl&lt;&lt; " 3) quick blow" &lt;&lt; endl;(cin &gt;&gt; choice).get();if (choice == 1){cout &lt;&lt; " you go for the accurate lunge, and manage to skewer the boar ";cout &lt;&lt; endl;cout &lt;&lt; " congratulations you have defeated the boar! ";}else if (choice == 2){cout &lt;&lt; " you go for the crushing blow and miss! ";cout &lt;&lt; endl;cout &lt;&lt; " the boar kills you! ";cout &lt;&lt; " better luck next time " &lt;&lt; name;}else{cout &lt;&lt; " you go for the quick lunge and luckily you manage to kill the boar! ";cout &lt;&lt; endl;cout &lt;&lt; " congratulations you have defeated the boar! ";}cout &lt;&lt; endl;cout &lt;&lt; " would you like to play again ? &lt;Y/N&gt; ";cin &gt;&gt; quit_choice;if (quit_choice == 'y' || quit_choice == 'Y'){cout &lt;&lt; " hope to see you again soon! ";}else if (quit_choice == 'n' || quit_choice == 'N'){cout &lt;&lt; " Nothing else to do so will quit anyways! ";}else {cout &lt;&lt; " you have not entered a valid option -- program will now quit! ";}}while (quit_choice == 'n' || quit_choice == 'N');cin.get();cin.get();return 0;}please help me guys i know you are all very kind :D   
  never mind it works it was just that there was a null character in between the name i used. sorry;  You probably want to support names longer than a single character. Use std::string for text in C++ (you will need to #include <string>). If you want people to be able to enter names with spaces, you can use the free function std::getline(std::cin, name) rather than operator >> (again, name will be a std::string instance).Other than that, I would point out that this line seems suspicous:(cin >> choice).get();You can replace it with just:cin >> choice;If you still want an artificial pause, better to do that on a separate line. This makes your code clearer.You can use the character literal '\n' rather than std::endl when you want a newline to appear in your program output. The difference is that std::endl flushes the buffers, which is usually unnecessary.At the very end of your program, you only need to do cin.get() once for a pause.   ;  i went with #include <iostream>using namespace std;int main(){char quit_choice;// outside game loop or else quit_choice not recogniseddo {// game loop hopefullyint choice;char name[20];cout << " to start this adventure please type in your name ";cin.getline(name, 20);cout << "\n";cout << " hello " << name;// add a bit of depth to game by including personal namescout << " you are a warrior and a boar attacks you ";cout << endl << " what do you do? \n " << " 1) accurate lunge \n" << << " 2) crushing blow \n" << << " 3) quick blow  \n" << ;cin >> choice;// used this to vary my input methodsif (choice == 1){cout << " you go for the accurate lunge, and manage to skewer the boar ";cout << "\n";cout << " congratulations you have defeated the boar! ";}else if (choice == 2){cout << " you go for the crushing blow and miss! ";cout << "\n";cout << " the boar kills you! ";cout << " better luck next time " << name;}else{cout << " you go for the quick lunge and luckily you manage to kill the boar! ";cout << " \n";cout << " congratulations you have defeated the boar! ";}cout << "\n";cout << " would you like to play again ? <Y/N> ";cin >> quit_choice;// simpe do you want to quit with play again option}while (quit_choice == 'y' || quit_choice == 'Y');// end of loopcin.get();// added to keep program running at finishreturn 0;}and thanks for the input :D much appreciated   ;  What if my name is longer than 19 characters? Use std::string, rather than become infected with the C Programmer's Disease.   ;Quote:Original post by rip-offWhat if my name is longer than 19 characters? Use std::string, rather than become infected with the C Programmer's Disease.Agreed!Why are you even bothering with a character array unless you are learning from an outdated tutorial or book?