int n; std::cin >> n; std::string s = \"\"; std::getline(cin, s);
I noticed that if I use cin, my program would hang the next t
cin
You need to clear the input stream - try adding the following after your cin:
cin.clear(); cin.ignore(std::numeric_limits::max(), '\n');
The accepted answer to this question gives a good explanation of why/when this is required.