The following is my code, I am reading data in from a file, and taking the data one line at a time and trying to insert it into a map. I am not allowed to use more then one map.
using namespace std;
int main( int argc, char* argv[]){
char* file = argv[1]; // saves name of file
ifstream infile ( file ); // Imported file
map <string, set < pair < string, string > > > m;
string data;
string key;
string year;
string count;
if(!infile){
cout << "Error opening file" << endl;
return -1;
}
while (!infile.eof() ){
getline(infile, data);
for ( unsigned int i = 0; i < data.length(); i++ ){
while ( data[i] != '\t'){
key += data[i];
i++;
}
i++;
while ( data[i] != '\t'){
year += data[i];
i++;
}
i++;
while ( data[i] != '\t'){
count += data[i];
i++;
}
cout << key << endl;
cout << year << endl;
cout << count << endl;
cout << endl;
break;
}
m.insert(key, set < pair < string, string > > ( year, count) );
key.clear();
year.clear();
count.clear();
}
}