I am attempting to write a program that will take a word as input from the user. The program will then find all of the words that can be used from the letters in the word the user inputted. A letter cannot be used twice if it only appears in the inputted word once, so if the inputted word has one o, no word with 2 o's can be formed. There will be a file that the code references that contains a dictionary of words that will be able to be formed. The code must be case insensitive. After a word is inputted, all of the anagrams for the word will be outputted, and the user will be asked for another word. This will continue until the user inputs a blank line.

I'm not sure how to approach writing this code, so any hints or help will be appreciated.

Given the dictionary contains what words can be formed, I see where we need the isAnagram() from
https://www.javatpoint.com/java-program-to-check-whether-two-strings-are-anagram-or-not

With that out of the way you proceed to write the rest of the code similar to this:

  1. Input the word.
  2. Open the dictionary.
  3. Loop
  4. Read a word from the dictionary.
  5. Test if the word and the dictionary word are an anagram.
  6. end loop if the end of the dictionary is reached.

The brute force search is a good solution for a small dictionary and a small number of searches, but gets very CPU intensive otherwise.
I hit this implementing a Scrabble solver where each move requires checking all the subsets of 7 or more letters against a dictionary of 230k words.
There's a solution that trades a 1 second startup cost for sub-microsecond searches. If anyone's interested I can share it here.
JC

Here's a way to get started. Searches a text file for similar words from characters, logs and displays them.

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;

ofstream logfile("log.txt", ios_base::app);
ofstream found_words("found.txt");

void menu();
int read();
int found();
//int user();

int main()
{   
    while (1) {
        menu();
        read();
        found();
    }
    return 0;
}

void menu()
{
    std::cout << " " << std::endl;
    std::cout << " Anagram / word finder" << std::endl;
    std::cout << " " << std::endl;

}

int read()
{   

    ofstream logfile("log.txt", ios::app);
    int l = 0;
    int debug = 0;
    string str = " ";
    std::cout << " Enter 5 letters or word: ";
    std::cin >> str;
    logfile << str << endl;
    for (int i = 0; str[i] != '\0'; ++i)
    {
        l++;
    }
    if (debug == 2) {
        std::cout << "\n Length: " << l << std::endl;
        logfile << "Length: " << l << std::endl;
    }
    std::string s = str;
    char uch = str[0];
    char uch2 = str[1];
    char uch3 = str[2];
    char uch4 = str[3];
    char uch5 = str[4];
    int ucount1 = 0;
    int ucount2 = 0;
    int ucount3 = 0;
    int ucount4 = 0;
    int ucount5 = 0;

    for (int i = 0; (i = s.find(uch, i)) != std::string::npos; i++) {
        ucount1++;
    }
    for (int i = 0; (i = s.find(uch2, i)) != std::string::npos; i++) {
        ucount2++;
    }
    for (int i = 0; (i = s.find(uch3, i)) != std::string::npos; i++) {
        ucount3++;
    }
    for (int i = 0; (i = s.find(uch4, i)) != std::string::npos; i++) {
        ucount4++;
    }
    for (int i = 0; (i = s.find(uch5, i)) != std::string::npos; i++) {
        ucount5++;
    }

    if (debug == 3) {
        logfile << "Character " << uch << " occurs " << ucount1 << " times" << " word: " << str << std::endl;
        logfile << "Character " << uch2 << " occurs " << ucount2 << " times" << " word: " << str << std::endl;
        logfile << "Character " << uch3 << " occurs " << ucount3 << " times" << " word: " << str << std::endl;
        logfile << "Character " << uch4 << " occurs " << ucount4 << " times" << " word: " << str << std::endl;
        logfile << "Character " << uch5 << " occurs " << ucount5 << " times" << " word: " << str << std::endl;
    }
    logfile << str << std::endl;
    if (debug == 3) {
        logfile << "1st: " << uch << " 2nd: " << uch2 << " 3rd: " << uch3 << " 4th: " << uch4 << " 5th: " << uch5 << std::endl;
        logfile << "counts: " << ucount1 << "\t" << ucount2 << "\t" << ucount3 << "\t" << ucount4 << "\t" << ucount5 << std::endl;
    }

    char data[100];

    int line = 0;

    ifstream rfile;
    std::cout << " Searching..." << std::endl;
    rfile.open("test.txt", ios::in | ios::out);
    ofstream found("found.txt");
    int fcount = 0;
    while (rfile) {
        rfile >> data;
        if (debug == 1) {
            std::cout << data[0];
            std::cout << data[1];
            std::cout << data[2];
            std::cout << data[3];
            std::cout << data[4];
            logfile << data[0];
            logfile << data[1];
            logfile << data[2];
            logfile << data[3];
            logfile << data[4];
        }

        std::string s = data;
        char ch = data[0];
        char ch2 = data[1];
        char ch3 = data[2];
        char ch4 = data[3];
        char ch5 = data[4];

        line = line + 1;
        int l = 0;

        for (int i = 0; data[i] != '\0'; ++i)
        {
            l++;
        }
        if (debug == 2) {
            std::cout << "\n Length: " << l << std::endl;
        }
        int counts = 0;
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        int count4 = 0;
        int count5 = 0;
        bool one = false;
        bool two = false;
        bool three = false;
        bool four = false;
        bool five = false;

        for (int i = 0; (i = s.find(ch, i)) != std::string::npos; i++) {
            count1++;
        }
        for (int i = 0; (i = s.find(ch2, i)) != std::string::npos; i++) {
            count2++;
        }
        for (int i = 0; (i = s.find(ch3, i)) != std::string::npos; i++) {
            count3++;
        }
        for (int i = 0; (i = s.find(ch4, i)) != std::string::npos; i++) {
            count4++;
        }
        for (int i = 0; (i = s.find(ch5, i)) != std::string::npos; i++) {
            count5++;
        }


        if (l <= 5 && l >= 5) {

            if (uch == ch) {
                if (debug == 1) {
                    cout << "1st match found" << " matches: " << data << endl;
                }
                one = true;
            }
            if (uch == ch2) {
                if (debug == 1) {
                    cout << "2nd match found" << " matches: " << data << endl;
                }
                one = true;
            }
            if (uch == ch3) {
                if (debug == 1) {
                    cout << "3rd match found" << " matches: " << data << endl;
                }
                one = true;
            }
            if (uch == ch4) {
                if (debug == 1) {
                    cout << "4th match found" << " matches: " << data << endl;
                }
                one = true;
            }
            if (uch == ch5) {
                if (debug == 1) {
                    cout << "5th match found" << " matches: " << data << endl;
                }
                one = true;
            }


            if (uch2 == ch) {
                if (debug == 1) {
                    cout << "1st match found" << " matches: " << data << endl;
                }
                two = true;
            }
            if (uch2 == ch2) {
                if (debug == 1) {
                    cout << "2nd match found" << " matches: " << data << endl;
                }
                two = true;
            }
            if (uch2 == ch3) {
                if (debug == 1) {
                    cout << "3rd match found" << " matches: " << data << endl;
                }
                two = true;
            }
            if (uch2 == ch4) {
                if (debug == 1) {
                    cout << "4th match found" << " matches: " << data << endl;
                }
                two = true;
            }
            if (uch2 == ch5) {
                if (debug == 1) {
                    cout << "5th match found" << " matches: " << data << endl;
                }
                two = true;
            }

            if (uch3 == ch) {
                if (debug == 1) {
                    cout << "1st match found" << " matches: " << data << endl;
                }
                three = true;
            }
            if (uch3 == ch2) {
                if (debug == 1) {
                    cout << "2nd match found" << " matches: " << data << endl;
                }
                three = true;
            }
            if (uch3 == ch3) {
                if (debug == 1) {
                    cout << "3rd match found" << " matches: " << data << endl;
                }
                three = true;
            }
            if (uch3 == ch4) {
                if (debug == 1) {
                    cout << "4th match found" << " matches: " << data << endl;
                }
                three = true;
            }
            if (uch3 == ch5) {
                if (debug == 1) {
                    cout << "5th match found" << " matches: " << data << endl;
                }
                three = true;
            }

            if (uch4 == ch) {
                if (debug == 1) {
                    cout << "1st match found" << " matches: " << data << endl;
                }
                four = true;
            }
            if (uch4 == ch2) {
                if (debug == 1) {
                    cout << "2nd match found" << " matches: " << data << endl;
                }
                four = true;
            }
            if (uch4 == ch3) {
                if (debug == 1) {
                    cout << "3rd match found" << " matches: " << data << endl;
                }
                four = true;
            }
            if (uch4 == ch4) {
                if (debug == 1) {
                    cout << "4th match found" << " matches: " << data << endl;
                }
                four = true;
            }
            if (uch4 == ch5) {
                if (debug == 1) {
                    cout << "5th match found" << " matches: " << data << endl;
                }
                four = true;
            }

            if (uch5 == ch) {
                if (debug == 1) {
                    cout << "1st match found" << " matches: " << data << endl;
                }
                five = true;
            }
            if (uch5 == ch2) {
                if (debug == 1) {
                    cout << "2nd match found" << " matches: " << data << endl;
                }
                five = true;
            }
            if (uch5 == ch3) {
                if (debug == 1) {
                    cout << "3rd match found" << " matches: " << data << endl;
                }
                five = true;
            }
            if (uch5 == ch4) {
                if (debug == 1) {
                    cout << "4th match found" << " matches: " << data << endl;
                }
                five = true;
            }
            if (uch5 == ch5) {
                if (debug == 1) {
                    cout << "5th match found" << " matches: " << data << endl;
                }
                five = true;
            }
            if (one && two && three && four && five == true) {
                if (ucount1 == count1 && ucount2 == count2 && ucount3 == count3 && ucount4 == count4 && ucount5 == count5) {    
                        if (debug == 2) {
                            std::cout << "Character " << ch << " occurs " << count1 << " times" << " word: " << data << std::endl;
                        }
                        if (debug == 3) {
                            found << "Character " << ch << " occurs " << count1 << " times" << " word: " << data << std::endl;
                            found << "Character " << ch2 << " occurs " << count2 << " times" << " word: " << data << std::endl;
                            found << "Character " << ch3 << " occurs " << count3 << " times" << " word: " << data << std::endl;
                            found << "Character " << ch4 << " occurs " << count4 << " times" << " word: " << data << std::endl;
                            found << "Character " << ch5 << " occurs " << count5 << " times" << " word: " << data << std::endl;
                        }
                        found << data << std::endl;
                        if (debug == 3) {
                            found << "1st: " << ch << " 2nd: " << ch2 << " 3rd: " << ch3 << " 4th: " << ch4 << " 5th: " << ch5 << std::endl;
                            found << "counts: " << count1 << "\t" << count2 << "\t" << count3 << "\t" << count4 << "\t" << count5 << std::endl;
                            found << "ucounts:" << ucount1 << "\t" << ucount2 << "\t" << ucount3 << "\t" << ucount4 << "\t" << ucount5 << std::endl;
                        }
                        if (debug == 2) {
                            std::cout << "1st: " << ch << " 2nd: " << ch2 << " 3rd: " << ch3 << " 4th: " << ch4 << " 5th: " << ch5 << std::endl;
                        }
                        fcount = fcount + 1;
                    }
                    if (debug == 1) {
                        std::cout << one << two << three << four << five << std::endl;
                    }
                    one = false;
                    two = false;
                    three = false;
                    four = false;
                    five = false;
                    if (debug == 2) {
                        std::cout << data << std::endl;
                }
            }
        }
    }

        std::cout << " Number of words in database: " << line << endl;
        std::cout << " Number of words found: " << fcount << endl;
        std::cout << "\n";
        rfile.close();
        logfile.close();    

        return 0;   
    }

    int found()
    {
        ifstream foundfile;
        string words;
        foundfile.open("found.txt");
        while (foundfile) {
            getline(foundfile, words);
            cout << words << endl;
        }
        foundfile.close();
        return 0;
    }

 Anagram / word finder

 Enter 5 letters or word: tires
 Searching...
 Number of words in database: 466551
 Number of words found: 5

resit
rites
tiers
tires
tries

A lot of repeated code that should use arrays, but without comments it’s unreadable anyway.
Did you test it with words that have repeated letters?
It’s also not Java.

Here’s a really neat algorithm:
Write a small method to sort the letters of a word into alphabetical order (let’s call it alpha).
Read the dictionary file creating a map with alpha(word) as the key and a list of corresponding words as the value.
Now you can look up all the matches for some anagram by getting the value for key alpha(anagram).

With the official Scrabble word list of 230k words building the map takes up to 1 second and occupies 10-20 Mbytes, but subsequent lookups are instantaneous.

I can post the code if anyone is interested.

Kewl. In Python that's a simple dict with key=sorted and val=list.

commented: Keel indeed. In Java it’s a HashMap for best performance +15

It’s also not Java.

The question was tagged both c++ and java. I don't think the OP has a preference, and can probably follow along with either.

commented: Maybe, but the title is pretty clear +15

To consider repeating letters you can just add a counter and modify your if statment.

    #include <iostream>
    #include <fstream>
    #include <string>
    #include <iomanip>

    using namespace std;

    ofstream logfile("log.txt", ios_base::app);
    ofstream found_words("found.txt");

    void menu();
    int read();
    int found();
    //int user();

    int main()
    {   
        while (1) {
            menu();
            read();
            found();
        }
        return 0;
    }

    void menu()
    {
        std::cout << " " << std::endl;
        std::cout << " Anagram / word finder" << std::endl;
        std::cout << " " << std::endl;

    }

    int read()
    {   

        ofstream logfile("log.txt", ios::app);
        int l = 0;
        int debug = 0;
        string str = " ";
        std::cout << " Enter letters or word: ";
        std::cin >> str;
        logfile << str << endl;
        for (int i = 0; str[i] != '\0'; ++i)
        {
            l++;
        }
        if (debug == 2) {
            std::cout << "\n Length: " << l << std::endl;
            logfile << "Length: " << l << std::endl;
        }
        std::string s = str;
        char uch = str[0];
        char uch2 = str[1];
        char uch3 = str[2];
        char uch4 = str[3];
        char uch5 = str[4];
        int ucount1 = 0;
        int ucount2 = 0;
        int ucount3 = 0;
        int ucount4 = 0;
        int ucount5 = 0;

        int ucounts = 0;
        ucounts = ucount1 + ucount2 + ucount3 + ucount4 + ucount5;

        for (int i = 0; (i = s.find(uch, i)) != std::string::npos; i++) {
            ucount1++;
        }
        for (int i = 0; (i = s.find(uch2, i)) != std::string::npos; i++) {
            ucount2++;
        }
        for (int i = 0; (i = s.find(uch3, i)) != std::string::npos; i++) {
            ucount3++;
        }
        for (int i = 0; (i = s.find(uch4, i)) != std::string::npos; i++) {
            ucount4++;
        }
        for (int i = 0; (i = s.find(uch5, i)) != std::string::npos; i++) {
            ucount5++;
        }

        if (debug == 3) {
            logfile << "Character " << uch << " occurs " << ucount1 << " times" << " word: " << str << std::endl;
            logfile << "Character " << uch2 << " occurs " << ucount2 << " times" << " word: " << str << std::endl;
            logfile << "Character " << uch3 << " occurs " << ucount3 << " times" << " word: " << str << std::endl;
            logfile << "Character " << uch4 << " occurs " << ucount4 << " times" << " word: " << str << std::endl;
            logfile << "Character " << uch5 << " occurs " << ucount5 << " times" << " word: " << str << std::endl;
        }
        logfile << str << std::endl;
        if (debug == 3) {
            logfile << "1st: " << uch << " 2nd: " << uch2 << " 3rd: " << uch3 << " 4th: " << uch4 << " 5th: " << uch5 << std::endl;
            logfile << "counts: " << ucount1 << "\t" << ucount2 << "\t" << ucount3 << "\t" << ucount4 << "\t" << ucount5 << std::endl;
        }

        char data[100];

        int line = 0;

        ifstream rfile;
        std::cout << " Searching..." << std::endl;
        rfile.open("words.txt", ios::in | ios::out);
        ofstream found("found.txt");
        int fcount = 0;
        while (rfile) {
            rfile >> data;
            if (debug == 1) {
                std::cout << data[0];
                std::cout << data[1];
                std::cout << data[2];
                std::cout << data[3];
                std::cout << data[4];
                logfile << data[0];
                logfile << data[1];
                logfile << data[2];
                logfile << data[3];
                logfile << data[4];
            }

            std::string s = data;
            char ch = data[0];
            char ch2 = data[1];
            char ch3 = data[2];
            char ch4 = data[3];
            char ch5 = data[4];

            line = line + 1;
            int l = 0;

            for (int i = 0; data[i] != '\0'; ++i)
            {
                l++;
            }
            if (debug == 2) {
                std::cout << "\n Length: " << l << std::endl;
            }
            int counts = 0;
            int count1 = 0;
            int count2 = 0;
            int count3 = 0;
            int count4 = 0;
            int count5 = 0;

            int ucnt1 = 0;
            int ucnt2 = 0;
            int ucnt3 = 0;
            int ucnt4 = 0;
            int ucnt5 = 0;

            int cnt1 = 0;
            int cnt2 = 0;
            int cnt3 = 0;
            int cnt4 = 0;
            int cnt5 = 0;

            int ucnts = 0;
            ucnts = ucnt1 + ucnt2 + ucnt3 + ucnt4 + ucnt5;

            bool one = false;
            bool two = false;
            bool three = false;
            bool four = false;
            bool five = false;

            for (int i = 0; (i = s.find(ch, i)) != std::string::npos; i++) {
                count1++;
            }
            for (int i = 0; (i = s.find(ch2, i)) != std::string::npos; i++) {
                count2++;
            }
            for (int i = 0; (i = s.find(ch3, i)) != std::string::npos; i++) {
                count3++;
            }
            for (int i = 0; (i = s.find(ch4, i)) != std::string::npos; i++) {
                count4++;
            }
            for (int i = 0; (i = s.find(ch5, i)) != std::string::npos; i++) {
                count5++;
            }


            if (l <= 5 && l >= 5) {

                if (uch == ch) {
                    if (debug == 1) {
                        cout << "1st match found" << " matches: " << data << endl;
                    }
                    ucnt1++;
                    cnt1++;
                    one = true;
                }
                if (uch == ch2) {
                    if (debug == 1) {
                        cout << "2nd match found" << " matches: " << data << endl;
                    }
                    ucnt1++;
                    cnt2++;
                    one = true;
                }
                if (uch == ch3) {
                    if (debug == 1) {
                        cout << "3rd match found" << " matches: " << data << endl;
                    }
                    ucnt1++;
                    cnt3++;
                    one = true;
                }
                if (uch == ch4) {
                    if (debug == 1) {
                        cout << "4th match found" << " matches: " << data << endl;
                    }
                    ucnt1++;
                    cnt4++;
                    one = true;
                }
                if (uch == ch5) {
                    if (debug == 1) {
                        cout << "5th match found" << " matches: " << data << endl;
                    }
                    ucnt1++;
                    cnt5++;
                    one = true;
                }


                if (uch2 == ch) {
                    if (debug == 1) {
                        cout << "1st match found" << " matches: " << data << endl;
                    }
                    ucnt2++;
                    cnt1++;
                    two = true;
                }
                if (uch2 == ch2) {
                    if (debug == 1) {
                        cout << "2nd match found" << " matches: " << data << endl;
                    }
                    ucnt2++;
                    cnt2++;
                    two = true;
                }
                if (uch2 == ch3) {
                    if (debug == 1) {
                        cout << "3rd match found" << " matches: " << data << endl;
                    }
                    ucnt2++;
                    cnt3++;
                    two = true;
                }
                if (uch2 == ch4) {
                    if (debug == 1) {
                        cout << "4th match found" << " matches: " << data << endl;
                    }
                    ucnt2++;
                    cnt4++;
                    two = true;
                }
                if (uch2 == ch5) {
                    if (debug == 1) {
                        cout << "5th match found" << " matches: " << data << endl;
                    }
                    ucnt2++;
                    cnt5++;
                    two = true;
                }

                if (uch3 == ch) {
                    if (debug == 1) {
                        cout << "1st match found" << " matches: " << data << endl;
                    }
                    ucnt3++;
                    cnt1++;
                    three = true;
                }
                if (uch3 == ch2) {
                    if (debug == 1) {
                        cout << "2nd match found" << " matches: " << data << endl;
                    }
                    ucnt3++;
                    cnt2++;
                    three = true;
                }
                if (uch3 == ch3) {
                    if (debug == 1) {
                        cout << "3rd match found" << " matches: " << data << endl;
                    }
                    ucnt3++;
                    cnt3++;
                    three = true;
                }
                if (uch3 == ch4) {
                    if (debug == 1) {
                        cout << "4th match found" << " matches: " << data << endl;
                    }
                    ucnt3++;
                    cnt4++;
                    three = true;
                }
                if (uch3 == ch5) {
                    if (debug == 1) {
                        cout << "5th match found" << " matches: " << data << endl;
                    }
                    ucnt3++;
                    cnt5++;
                    three = true;
                }

                if (uch4 == ch) {
                    if (debug == 1) {
                        cout << "1st match found" << " matches: " << data << endl;
                    }
                    ucnt4++;
                    cnt1++;
                    four = true;
                }
                if (uch4 == ch2) {
                    if (debug == 1) {
                        cout << "2nd match found" << " matches: " << data << endl;
                    }
                    ucnt4++;
                    cnt2++;
                    four = true;
                }
                if (uch4 == ch3) {
                    if (debug == 1) {
                        cout << "3rd match found" << " matches: " << data << endl;
                    }
                    ucnt4++;
                    cnt3++;
                    four = true;
                }
                if (uch4 == ch4) {
                    if (debug == 1) {
                        cout << "4th match found" << " matches: " << data << endl;
                    }
                    ucnt4++;
                    cnt4++;
                    four = true;
                }
                if (uch4 == ch5) {
                    if (debug == 1) {
                        cout << "5th match found" << " matches: " << data << endl;
                    }
                    ucnt4++;
                    cnt5++;
                    four = true;
                }

                if (uch5 == ch) {
                    if (debug == 1) {
                        cout << "1st match found" << " matches: " << data << endl;
                    }
                    ucnt5++;
                    cnt1++;
                    five = true;
                }

                if (uch5 == ch2) {
                    if (debug == 1) {
                        cout << "2nd match found" << " matches: " << data << endl;
                    }
                    ucnt5++;
                    cnt2++;
                    five = true;
                }
                if (uch5 == ch3) {
                    if (debug == 1) {
                        cout << "3rd match found" << " matches: " << data << endl;
                    }
                    ucnt5++;
                    cnt3++;
                    five = true;
                }
                if (uch5 == ch4) {
                    if (debug == 1) {
                        cout << "4th match found" << " matches: " << data << endl;
                    }
                    ucnt5++;
                    cnt4++;
                    five = true;
                }
                if (uch5 == ch5) {
                    if (debug == 1) {
                        cout << "5th match found" << " matches: " << data << endl;
                    }
                    ucnt5++;
                    cnt5++;
                    five = true;
                }
                if (one && two && three && four && five == true){

                        if(ucnt1 == ucount1 && ucnt2 == ucount2 && ucnt3 == ucount3 && ucnt4 == ucount4 && ucnt5 == ucount5) {

                            if (debug == 2) {
                                std::cout << "Character " << ch << " occurs " << count1 << " times" << " word: " << data << std::endl;
                            }
                            if (debug == 3) {
                                found << "Character " << ch << " occurs " << count1 << " times" << " word: " << data << std::endl;
                                found << "Character " << ch2 << " occurs " << count2 << " times" << " word: " << data << std::endl;
                                found << "Character " << ch3 << " occurs " << count3 << " times" << " word: " << data << std::endl;
                                found << "Character " << ch4 << " occurs " << count4 << " times" << " word: " << data << std::endl;
                                found << "Character " << ch5 << " occurs " << count5 << " times" << " word: " << data << std::endl;
                            }
                            found << data << std::endl;
                            if (debug == 3) {
                                    found << cnt1 << "\t" << cnt2 << "\t" << cnt3 << "\t" << cnt4 << "\t" << cnt5 << std::endl;
                                    found << ucnt1 << "\t" << ucnt2 << "\t" << ucnt3 << "\t" << ucnt4 << "\t" << ucnt5 << std::endl;
                                    found << cnt1 << "\t" << cnt2 << "\t" << cnt3 << "\t" << cnt4 << "\t" << cnt5 << std::endl;
                                found << "1st: " << ch << " 2nd: " << ch2 << " 3rd: " << ch3 << " 4th: " << ch4 << " 5th: " << ch5 << std::endl;
                                found << "counts: " << count1 << "\t" << count2 << "\t" << count3 << "\t" << count4 << "\t" << count5 << std::endl;
                                found << "ucounts:" << ucount1 << "\t" << ucount2 << "\t" << ucount3 << "\t" << ucount4 << "\t" << ucount5 << std::endl;
                            }
                            if (debug == 2) {
                                std::cout << "1st: " << ch << " 2nd: " << ch2 << " 3rd: " << ch3 << " 4th: " << ch4 << " 5th: " << ch5 << std::endl;
                            }
                            fcount = fcount + 1;
                        }
                        if (debug == 1) {
                            std::cout << one << two << three << four << five << std::endl;
                        }
                        one = false;
                        two = false;
                        three = false;
                        four = false;
                        five = false;

                        ucnt1 = 0;
                        ucnt2 = 0;
                        ucnt3 = 0;
                        ucnt4 = 0;
                        ucnt5 = 0;
                        ucnts = 0;

                        if (debug == 2) {
                            std::cout << data << std::endl;
                        }
                }
            }
        }

            std::cout << " Number of words in database: " << line << endl;
            std::cout << " Number of words found: " << fcount << endl;
            std::cout << "\n";
            rfile.close();
            logfile.close();    

            return 0;   
        }

        int found()
        {
            ifstream foundfile;
            string words;
            foundfile.open("found.txt");
            while (foundfile) {
                getline(foundfile, words);
                cout << words << endl;
            }
            foundfile.close();
            return 0;
        }

 Anagram / word finder

 Enter letters or word: treat
 Searching...
 Number of words in database: 466552
 Number of words found: 6
 //Elapsed time: 48 ms

atter
tarte
tater
teart
tetra
treat
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.