word generator

Discussion in 'C++' started by badboy1245, Sep 22, 2015.

  1. badboy1245

    badboy1245 New Member

    Joined:
    Sep 21, 2015
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Here is the program im trying to get to work. it opens a list of words into memory and than you type in letters and it compares the letters to the word and if the the letters match the word it should print it out but for some reason its not match the letters to the word. and i don't know what i'm doing wrong. could some one have a look and get it working for me. thanks


    Code:
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include <fstream>
    #include <vector>
    using namespace std;
    
    int main()
    {
    
    vector<string> epw,lt;
    string rpl;
    char b_board[50];
    string addletters;
    int c,aos,cc,only_first_word;
    char l_to_c[50];
    char board[50];
    char letters_to_add[50];
    char hold_word[50];
    char letter_to_compare[50];
    char enter_p_word[50];
    char first[50];
    char second[50];
    
    char enterletters[50];
    char letter[50];
    char fletter[50];
    char enterletters_2[50];
    char holdletters[50];
    char saved_word[50];
    char enterlet[50];
    int saved_number;
    int second_length;
    
    int first_length;
    
    cout <<" " <<endl;
    
    saved_number=0;
    vector<string> firs;
    ifstream inu("Dictionary.txt");
    string word;
    int nw;
    int turn_on_board=0;
    while(inu >> word)
    firs.push_back(word);
    inu.close();
    int turn_on_biggest_word=1;
    
    begin:
    
    
    cout << " "<<endl;
    cout <<"Enter letters: ";
    cin >> enterletters_2;
    cc=0;
    
    
    strcpy (enterletters,enterletters_2);
    
    if (strcmp(enterletters_2,"0") == 0)
    return 0;
    
    
    
    
    int m=0;
    int match;
    
    printwords:
    for (int x=0; x<firs.size(); x++){
    
    nextword:
    strcpy (first,firs[x].c_str());
    strcpy ( second,enterletters);
    
    int first_length = strlen(first);
    int second_length = strlen(enterletters);
    second_length=second_length-1;
    
    c=0;
    
    for (int cycle=0; cycle<first_length; cycle++){
    
    
    nextletter:
    for ( match=0; match<second_length+1; match++){
    
    if (first[cycle] == second[match]) {
    
    memcpy(&second[match], &second[match+1], second_length-match);
    second_length++;
    c=c+1;
    
    
    
    
    if (c==first_length)
    cout <<"-------"<<first << endl;
    
    
    cycle=cycle+1;
    
    
    }
    
    }
    
    
    
    }
    
    }
    
    
    }
     
    Last edited by a moderator: Sep 22, 2015

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice