I want to find the words written to file1.txt in file2.txt
<p>my code is suppose to print out a list of random four-letter strings and compare them                     to a second file of a list of actual four letter words to check how many of my randon strings are real words but so far i can only do a handful of words(inputfile.txt has several thousand words to compae to file2)   </p>

<hr>

<pre><code>#include &lt;string&gt;
#include &lt;ctime&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;cmath&gt;
#include &lt;iomanip&gt;

using namespace std;    
static unsigned int Q[41790],indx=41790,carry=362436,xcng=1236789,xs=521288629;
unsigned int refill()// refill f(n) for SuperKISS
{
int i;
unsigned long long t;
for (i=0;i&lt;41790;i++)
{
    t = 7010176ULL * Q[i] + carry;
    carry = (t&gt;&gt;32);
    Q[i] = ~t;
}
indx=1;
return (Q[0]);
}
unsigned int SuperKISS()//randon number sedd
{
xcng = 69069 * xcng + 123;
xs ^= xs&lt;&lt;13;
xs ^= xs&gt;&gt;17;
xs ^= xs&gt;&gt;5;
return (indx&lt;41790 ? Q[indx++] : refill()) + xcng + xs;
}

char createRandstr(string alphaRand)
{
    int stringLength = sizeof(alphaRand) - 1;

    char randstrn = alphaRand[rand() % stringLength];
    return randstrn;
}

int main()
{
    string alphaRand = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    srand(SuperKISS()*time(0));              
    int numofstrings = 10000;
    ofstream myfile("/Users/Projects/ScrabbleWordFinder/output.txt");

    if (myfile.is_open())
    {    
        for (int i=0; i &lt; numofstrings; i++)
        {
        cout &lt;&lt; createRandstr(alphaRand) &lt;&lt; createRandstr(alphaRand) &lt;&lt;               createRandst(alphaRand) &lt;&lt; createRandstr(alphaRand) &lt;&lt; endl;
        myfile &lt;&lt; createRandstr(alphaRand) &lt;&lt; createRandstr(alphaRand) &lt;&lt; createRandstr(alphaRand) &lt;&lt; createRandstr(alphaRand) &lt;&lt; endl;
        myfile.clear();
        }
        myfile.close();
        cout &lt;&lt; endl;
        cout &lt;&lt; "Done printing to file " &lt;&lt; endl;
        }     
        else cout &lt;&lt; "Unable to open file" &lt;&lt; endl;
        exit(1); // terminate with error
        return 0;
}
/*the code i dont know how to make work is as follows are the follwing two, i dont know how to make it search the whole output file for more than one word at a time*/

//int main ()
{
    string line;
    ifstream Myfile("/UsersProjects/ScrabbleWordFinder/output.txt");
    if(Myfile.is_open())
    {
        while(!Myfile.eof())
        {
            char* search = "LARD"; // search pattern
            int offset; // where it was found (or not (-1))
            getline(Myfile,line);
            cout&lt;&lt;line&lt;&lt;endl;
            // arg 2 (0) specifies the offset from where to begin seach
            if ((offset = line.find(search, 0)) != string::npos)
        }    
        cout &lt;&lt; "found '" &lt;&lt; search &lt;&lt; "' @ offset " &lt;&lt; offset &lt;&lt; endl;
        cin.get();
    }
    else
    Myfile.close();
    cout&lt;&lt;"Unable to open this file."&lt;&lt;endl; 
    return 0;
}
/*Or something like this*/
int main()
{
    string Dest[3] = {"ZOON", "LARD", "NOON"} ;
    // Creating a ifstream object to read from the text file data.txt...
    ifstream     readFromFile("/Users/Projects/ScrabbleWordFinder/ScrabbleWordFinder/output.txt");

    // Creating a string variable.
    string output;
    string data;
    while(!readFromFile.eof())
    { 
        getline(readFromFile,data);
        for (int i = 0; i &lt; 3; i++)
        //find word in file
        {  
            if (data.find(Desti[i])!=string::npos)//search for word 
            {    
                cout &lt;&lt; Dest[i] &lt;&lt; endl;//look for word                                  
                cout &lt;&lt; data &lt;&lt; endl;//cout word found
            }
        }    
    }
} 
</code></pre>
