You seem to be unclear on map. A map stores the data. It does not parse the data. You will need to:
Read the words from the file. This can be done either one by one, or you can read the file one line at a time and tokenize the line. My suggestion is to read the words one at time.
Come up with the data structure to store the data. My suggestion:
std::map<std::string, std::vector<std::pair<int, int>>>
The key in the map is, obviously, the word. The
std::pair<int, int>
holds a line number and the number of occurrences of that word in that line. Thestd::vector<std::pair<int, int>>
allows you capture a list of thosestd::pair
s.
Hope this helps you to move forward.