Hoi,
wou ik eens c++ oefenen, met het begin en kom ik al meteen iets vreemd tegen.
Code:
#include <string>
#include <iostream>
int main() {
using namespace std;
const int THISYEAR = 2012;
string yourName;
string gameName;
int height;
int birthYear;
cout << " What is your name? " << flush;
//cin >> yourName;
getline(cin, yourName);
cout << "What year were you born? " ;
cin >> birthYear;
cout << "How tall are you (cm)? ";
cin >> height;
cout << "What is the name of your favorite game? " << flush;
getline(cin, gameName);
cout << "Your name is " << yourName
<< " and you are approximately "
<< (THISYEAR - birthYear)
<< " years old. " << endl << "You are " << height
<< "cm's tall and your favourite game is " << gameName << endl;
}
Ik krijg nooit de kans om m'n favoriete game in te geven, waarom niet? met cin >> gameame lukt het wel maar dan kan ik geen gespacieerde namen ingeven als je begrijpt wat ik bedoel.
Kan iemand even checken?