I have a main that
I want to use getline to get the user's words after i do a strtok to eliminate these delimiters (" ,.-")
and then find the soundex code of each word and insert the words into my hashtable.
i made an attempt but i was not getting anything. please help.
int main(int argc, char * argv[])
{
//argv takes in whatever the user passes.
//Hashtable dwords;
ifstream fin;
char * info = "/home/jclark/bin/words";// takes in a dictionary from this link.
char * code;
char c[40];
char * pch;
char buff[50];
if((argc > 1)&& !strcmp(argv[1], "-d") && (argc > 2))
{
info = argv[2];
//usrinput = argv[2];
/*cin.getline(usrword, 80);
pch = strtok(argv[2], " ,.-");
cout << "got to the first stuff"<<endl;
while(pch != NULL)
{
cout<< "got into while loop" <<endl;
cin.getline(usrword, 80);
pch = strtok(NULL, " ,.-");
if(pch == NULL)
{
exit(1);
}
}
}*/ //my attempt of the getline strtok stuff
//cout << "this is the end of the loop" <<endl;
//info = usrword;
//i am workign here at the moment to try the strtok
fin.open(info);
if (fin.is_open())
{
//fin.getline(buff, 50);
//pch = strtok(NULL, " ,.-");
fin >> c;
while(!fin.eof())
{
code = soundex(c);
cout << c << " "<< code << endl;
//dwords.insert(c, code);
fin >> c;
}
}
fin.close();
fin.clear();
return 0;
}