console application - How to use the same letter for an int and cin keyboard input C++ -


hi want use same letter int , cin keyboard input when enter in new number changes number in cell when enter score in keyboard sample code take account i'm still beginner , still learning:

int h = 0;  cout << " _______________________" << endl;  cout << "|chelsea fc |"<< h << "|" << endl;  cout << "|___________|__________|" << endl;   string h = "";   cout << "type here add score table" << endl;  getline(cin, h);   cout << "you added score " << h << " table" << endl; 

if understand correctly, want this:

int score = 0;  cout << " _______________________" << endl;  cout << "|chelsea fc |"<< score << "|" << endl;  cout << "|___________|__________|" << endl;   cout << "type here add score table" << endl;  cin >> score;  cout << "you added score " << score << " table" << endl; 

remember when reading numbers , strings, using input operator >> reads and discards leading white-space in input, if there newline in input buffer after input of score, if attempt read new number or string newline ignored.


Comments