How to use “gets” function in C++ after previous input?
问题 I tried to input data with gets() function, but whenever program execution get to the the lien with the gets , it ignores it. When I use gets() without previous data input, it runs properly. But when I use it after data input the problem happens. Here's the code where it is used after previous data input (so in execution I can't input data to string): int main() { char str[255]; int a = 0; cin >> a; if(a == 1) { gets(str); cout << "\n" << str << endl; } } How could I fix this? NB: the same