Мне нужно каждой строке из файла присвоить номер в порядке возрастания и по этому номеру как ключу в map работать с отдельной строкой.
Второй вопрос: как использовать string в stl, чтобы было что-то наподобие массива и обращаться к каждому элементу массива как word[i].
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <map>
int main()
{
setlocale (LC_ALL, ".866");
setlocale (LC_ALL, ".1251");
std::ifstream ifs("file.txt");
std::map<std::string, int> table;
std::string word;
while(ifs >> word)
{
table[word]++;
}
for(std::map<std::string, int>::iterator it = table.begin(); it != table.end(); it++)
{
std::cout << it->first << " " << it->second << std::endl;
}
system("pause");
return 0;
}