[Solved] C++ cin don’t work properly [closed]

The line World(height, width); constructs a temporary object and discards it. The member variable of the current object never get initialized properly. Simplify your code. Move the code to get input data to the function that calls it. For example, use it in main. int width = -1; int height = -1; cout << “Aby … Read more

[Solved] c++ getline and ignore

When you write cin.ignore(0,’\n’), you’re saying “Ignore the characters in the stream until you have ignored 0 characters or you reach a ‘\n’”. Since you told the stream to ignore a maximum of 0 characters, it does nothing. When you write cin.ignore(100, ‘\n’), you’re saying “Ignore the characters in the stream until you have ignored … Read more

[Solved] how to ask for input again c++

int main() { string calculateagain = “yes”; do { //… Your Code cout << “Do you want to calculate again? (yes/no) ” cin >> calculateagain; } while(calculateagain != “no”); return 0; } Important things to note: This is not checked, so user input may be invalid, but the loop will run again. You need to … Read more