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; }

15th Jul 2025, 7:32 AM
Md Mehedi Hasan
Md Mehedi Hasan - avatar
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.
15th Jul 2025, 7:43 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar