0
What is the problem with this code?
#include<iostream> #include<sstream> #include<string> using namespace std; int main() { string str = ""; int n; cin >> n; cin.ignore(); for(int i = 0; i < n; i++) { string name, first, last; getline(cin, name); stringstream ss(name); ss >> first >> last; str += first[0]; str += last[0]; if(i < n-1) { str += " "; } } cout << str << endl; return 0; }
1 Odpowiedź
0
Hey,
The code works as expected. But the line ` for(int i = 0; i < n; i++) {` seems to contain some invalid characters (shows up for me as <200c>).
That's likely why u are getting the error.