visual studio - C++: Iterate Through Map -


i'm trying iterate through map read out string , of numbers in vector file. copied , pasted typedef line, adjusted code, i'm not positive it's correct. anyways, visual studio giving me errors on use of iterator_variable in loops. says type name not allowed. how can fix this?

ofstream output("output.txt"); typedef map<string, vector<int>>::iterator iterator_variable; (iterator_variable iterator = misspelled_words.begin(); iterator != misspelled_words.end(); iterator++) {     output << iterator_variable->first;     (int = 0; < misspelled_words.size(); i++)     {         output << " " << iterator_variable->second[i];     }     output << endl; } 

you should access iterator iterator->first instead of iterator_variable->first.

and inner loop, want iterate through 0 iterator->second.size() instead of misspelled_words.size().

ofstream output("output.txt"); typedef map<string, vector<int>>::iterator iterator_variable; (iterator_variable iterator = misspelled_words.begin(); iterator != misspelled_words.end(); iterator++) {     output << iterator->first;     (int = 0; < iterator->second.size(); i++)     {         output << " " << iterator->second[i];     }     output << endl; } 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -