|
|
back to board@Admin : some problem about string in C++ First, plz read my source. #include <iostream> #include <cstdio> #include <vector> #include <map> using namespace std; int main() { map <string, int> forum; string s;
while ( getline (cin, s)) { if (s == (string)"tram") forum["tram"]++; if (s == (string)"trolleybus") forum["trolleybus"]++; } if (forum["trolleybus"] > forum["tram"]) cout << "Trolleybus driver" << endl; if (forum["trolleybus"] < forum["tram"]) cout << "Tram driver" << endl; else cout << "Bus driver" << endl;
system("pause"); return 0; } Ok. This solution's result is "Compilation error". One of its : e8411d95-0fcd-44e7-941f-abd986747ed6(13): error: identifier "getline" is undefined while ( getline (cin, s)) ^ But I've seen FAQs, "getline" just use <iostream>. I don't why but I think my solution is take another error, not a "Compilation error". Plz explain ! Thank you very much ! P.S : Sorry about my bad English. Re: @Admin : some problem about string in C++ add #include <string> |
|
|