Below is what I use in Visual studio. Using getline I can have names entered that have spaces etc. If there is a space and I use cin, I get an infinite loop. (other code doesn't matter, it's just a function call.
All variables have been declared ok. What do I use insteasd of clear buffer etc on OS X?
All variables have been declared ok. What do I use insteasd of clear buffer etc on OS X?
Code:
void GetString(char* str) {
cout << "Please Enter a String: " << endl;
cin >> str;
// cin.ignore(cin.rdbuf()->in_avail());
//cin.getline(str, 100);
// cin.clear();
//cin.ignore(cin.rdbuf ()->in_avail());
cout << endl;
}