I'm new to c++ but i just try to make a simple text based game and the cin command wasnt working for the second time i was using it here is a chuck of my code.
#include <iostream>
using namespace std;
int sticks = 0;
int health = 100;//players health
int rocks = 0;
int pickaxehealth = 50;
int swordhealth = 50;
char name;
int main()
{
int direction1;
cout << "Welcome to Classic Text 1.0." << endl;
cout << "____________________________" << endl;
cout << " Enter your name: ";
cin >> name;
cout << "You wake up in the middle of the night, In a" << endl <<
"clearing of a forest. There is a path to the" << endl <<
"left and the right. Which way do you want to go" << endl;
cout << "_______________________________________________" << endl;
cout << " Type 1 to go right. Type 2 to go left"<< endl;
cout << "Enter which way you want to go: " << endl;
cin >> direction1;
every thing works zhuge but it doesn't allow the user to type in direction1. it shut down the program with out asking you what you what to import for direction1.
Even if it's not the problem you are currently having, you should change it still because your variable name is only withholding the first character you input.
You send a stream (std::cin) to a char pointer (for one or more chars but pointer) Stream need a buffer.
Declare name as: char name[32]. Now if std::cin data are less than 32 std::cin frees its space and send new data.
In your program std::cin access to direction but still have char data because name holds only the 1st byte.