Simple search engine using maps
Hi, for my last assignment I must make a program that takes in up to six files through the command line then print out the files in order of highest relavance depending on how many times the 2 keywords appear in each file. This is what I have so far but i'm getting a segmentation fault and I think it has something to do with the array of maps at line 24 but im not sure.
Code:
#include <fstream>
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
map<string, int> info[argc-1];
string fileNames[argc-1];
string word;
string keyword = "key";
for(int i=1; i < argc; i++)
{
fileNames[i] = argv[i];
info[i] = map<string, int>;
ifstream fin(argv[i]);
if(!fin) exit(1);
while(!fin.eof())
{
fin>>word;
if(info[i].count(word) <0 )
info[i][word];
else
info[i][word]++;
}
}
for(int i =0; i< info[i].size(); i++)
for(map<string, int>::iterator x = info[i].begin(); x != info[i].end(); x++)
cout<< x->first << ": "<< x->second << "\n";
}