mercredi 21 août 2019

I'm trying to get user input for char array in an if statement - C++

I'm tryin to get user input to a char array in a if statement. But the cin.get() function doesn't allow the user to enter anything.

I tried using cin.get(), cin.getline(), but nothing works. When I change the position of the question and input and move them out of the if statement, it works.

if(choiceOne == 'A'){
ofstream outfile;
outfile.open("u.txt");
newUser New; //new class object

char something[80];

cout << "Enter something: ";
cin.get(something, 80);
}

The code above results in skipping the cin.get and it continues to run the program.

Aucun commentaire:

Enregistrer un commentaire