I have a simple question (I think so) about fflush()
in C++.
Every time I write some code to input string in C++, I have to try many many ways because My program caused Error every time.
So I will ask a very simple question.
My code here:
void main()
{
int n;
string str;
cin >> n;
fflush(stdin);
fflush(stdin);
getline(cin, str);
cout << n << endl << str << endl;
}
and the compiler does not allow me to enter the string str
, how can I do that now?
And I don't want to talk about cin.ignore()
here, just about only fflush()