Я читаю из файла и беру слова в качестве токенов с strtok. Я пытаюсь сохранить слова в структуре карты. Я не знаю, как вставить маркеры на карту.Текст Гистограмма, маркеры, сохраненные на карте
Мой код до сих пор:
#include <iostream>
#include <string.h>
#include <fstream>
#include <map>
using namespace std;
//std::map <string, int> grade_list;
int main()
{
std::map <string, int> grade_list;
char text[100];
int nr=0, i=1;
char *ptr;
ifstream myfile("ana.txt");
if(!myfile.is_open())
cout << "Could not open file" << endl;
else
{
myfile.get(text, 100);
ptr = strtok(text, " ,.-?!");
while(ptr != NULL)
{
nr++;
cout << ptr << endl;
ptr = strtok(NULL, " ,.-?!");
grade_list.insert(ptr);
i++;
}
}
cout << "\nAveti " << nr << " cuvinte." << endl;
return 0;
}
можно вставить с помощью команды вставки. Взгляните на примеры здесь http://www.cplusplus.com/reference/map/map/insert/ – Pradheep
http://www.cplusplus.com/reference/map/map/operator%5B%5D/ – banuj