Thanks for the quick reply.
Is there any way to read in and process multiple words from the same line and then return to a menu? More specifically, I wrote a small proggy that searches a dictionary file for a match to a word that the user inputs. I would like to be able to enter multiple words on the same line seperated by spaces and have the proggy reply with whether or not each word is in the dictionary. Currently I can do this, but between words the proggy still displays the "Enter a word:" message. I would like it to reply for each word and then display "Enter a word:" again.
Heres my current code for this working program:
Code:
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
ifstream fin;
char fname[32];
char string1[64];
char string2[64];
int result;
int result2;
int search();
int main(int argc, char *argv[])
{
while (1==1)
{
cout << "Enter the word:";
search();
}
return 0;
}
int search()
{
int match = 0;
cin >> string1;
fin.open("dictionary.txt", ios::in);
while( !fin.eof() )
{
fin >> string2;
result = _stricmp( string1, string2 );
if (result == 0)
{
match = 1;
cout << string1 << " is a valid word\n\n";
}
}
if (match != 1)
{
cout << string1 << " is not a valid word\n\n";
}
fin.close();
fin.clear();
return 0;
}