converting c++ programming to use more advanced techniques
<p>I wrote a c++ program using simple techniques (with a lot of help from the community here), and now I've been trying to brush up on some more advanced c++ techniques. I already see the opportunity for dynamic memory with the 'words' array and some of the others. What other parts of the program should I change to use better/more advanced programming techniques?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;
using namespace std;

bool yesletter,alreadyguess;
int i(0),n(0),counter(0),limit(0),length,mastercount(0),yescount,numletters(0),guesses(0);
int letter[26];
int letters[2][26];
int placeletters[8];
char guess;
char prevguess[26];
char words[110000][30];
char letterans;


void initarray() {

    int len(0);
    string line;
    char temp;

    ifstream wordlist ("wordlist.txt");

    if (wordlist.is_open())
    {
        while (wordlist.good())
        {
            getline (wordlist,line);
            len=line.length();

            for (n=0;n&lt;30;n++)
            {
                if (n&lt;len){
                    temp=line.at(n);
                    words[i][n]=temp;
                }
                else{
                    words[i][n]='*';
                }
            }

            i++;
            counter++;
        }
    }
    else
    {
        cout&lt;&lt;"file not opened";
    }
    wordlist.close();
}

void selectlength()
{
    int x(0),y(0);
    bool shorter(false),longer(false);

    cout &lt;&lt;"length of word"&lt;&lt;endl;
    cin &gt;&gt; length;

    limit=counter;
    counter=0;

    for (i=0;i&lt;limit;i++){

        shorter=false;
        longer=false;

        for (n=0;n&lt;length;n++){
            if (words[i][n]=='*')
            {
                shorter=true;
                break;
            }
        }

        if (words[i][length] != '*')
        {
            longer=true;
        }

        if (!longer &amp;&amp; !shorter)
        {
                n=0;
                for (y=0;y&lt;30;y++)
                {
                    if (n&lt;length){
                        words[x][y]=words[i][n];
                        n++;
                    }
                    else{
                        words[x][y]='*';
                    }
                }
                x++;
                counter++;

        }

    }
}

void mostletters(){
    int temp,x;

    for (x=0;x&lt;26;x++){
        letter[x]=0;
    }
    for (i=0;i&lt;counter;i++){
        for (n=0;n&lt;=length;n++){

            temp=words[i][n]-97;
            if (temp&gt;=0 &amp;&amp; temp&lt;26)
            {
                letter[temp]++;
            }
        }
    }
}

void guessmost(){
    int x,y,temp,temp2;

    for (x=0;x&lt;26;x++){

        letters[0][x]=x;

        letters[1][x]=letter[x];

    }


    for (y=0;y&lt;26;y++){
        for (x=25;x&gt;=1;x--){
            if (letters[1][x]&gt;letters[1][x-1])
            {
                temp=letters[1][x-1];
                letters[1][x-1]=letters[1][x];
                letters[1][x]=temp;

                temp2=letters[0][x-1];
                letters[0][x-1]=letters[0][x];
                letters[0][x]=temp2;
            }
        }

    }
}

void letterguess(){
    int z,q;

    numletters=0;
    yesletter=false;
    alreadyguess=false;

        guess=letters[0][yescount]+97;

        if (mastercount==0){
            alreadyguess=false;
        }
        else{
            for (z=mastercount-1;z&gt;=0;z--){
                if (guess==prevguess[z]){
                    alreadyguess=true;
                    yescount++;
                }
            }
        }

        if (!alreadyguess){
            if (letters[1][yescount]==0){
                return;
            }
            cout&lt;&lt;"does the word contain ";
            if (guess=='a' || guess=='e' || guess=='f' || guess=='h' || guess=='i' || guess=='l' || guess=='m' || guess=='n' || guess=='o' || guess=='r' || guess=='s' || guess=='x'){
                cout&lt;&lt;"an ";
            }
            else{
                cout&lt;&lt;"a ";
            }
            cout&lt;&lt;guess&lt;&lt;"? ([y]es, [n]o, [r]estart)"&lt;&lt;endl;
            cin &gt;&gt; letterans;
            if (letterans=='r'){
                return;
            }
            else if (letterans=='y' ){
                yesletter=true;
            }
            else{
                yesletter=false;
            }
            prevguess[mastercount]=guess;
            mastercount++;

            if (yesletter){
                cout&lt;&lt;"how many?"&lt;&lt;endl;
                cin&gt;&gt;numletters;
                for (q=0;q&lt;numletters;q++){
                    if (numletters&gt;1){
                        cout&lt;&lt; "where is the "&lt;&lt;q+1;
                        if (q==0){
                            cout&lt;&lt;"st ";
                        }
                        else if (q==1){
                            cout&lt;&lt;"nd ";
                        }
                        else if (q==2){
                            cout&lt;&lt;"rd ";
                        }
                        else{
                            cout&lt;&lt;"th ";
                        }
                    }
                    else{
                        cout&lt;&lt;"where is the ";
                    }
                    cout&lt;&lt;guess&lt;&lt;"?"&lt;&lt;endl;
                    cin&gt;&gt; placeletters[q];
                }
                yescount=0;
            }
            else{
                guesses++;
            }
    }
}

void yesguess(){

    int x(0),y(0),q(0),temp(0);

    for (q=0;q&lt;numletters;q++){
        limit=counter;
        counter=0;
        x=0;
        temp=placeletters[q]-1;

        for (i=0;i&lt;limit;i++){

            if (words[i][temp]==guess){
                n=0;
                for (y=0;y&lt;30;y++)
                {
                    words[x][y]=words[i][n];
                    n++;
                }
                x++;
                counter++;
            }
        }
    }
}

void extraletters(){
    int x(0),y(0),q(0),temp(0);
    bool hasextra;

    limit=counter;
    counter=0;

    for (i=0;i&lt;limit;i++){
        hasextra=false;

        for (n=0;n&lt;length;n++){

            if (words[i][n]==guess){
                for (q=0;q&lt;numletters;q++){
                    temp=placeletters[q]-1;
                    if (n==temp){
                        hasextra=false;
                        break;
                    }
                    else{
                        hasextra=true;
                    }
                }
                if (hasextra){
                    break;
                }
            }
        }


        if (!hasextra)
        {
                n=0;
                for (y=0;y&lt;length;y++)
                {
                    if (n&lt;length){
                        words[x][y]=words[i][n];
                        n++;
                    }
                    else{
                        words[x][y]='*';
                    }
                }
                x++;
                counter++;

        }
    }
}

void noguess(){
    int x(0),y(0);
    bool hasletter(false);
    limit=counter;
    counter=0;
    for (i=0;i&lt;limit;i++){

        hasletter=false;

        for (n=0;n&lt;length;n++){

            if (words[i][n]==guess){
                hasletter=true;
            }
        }

        if (!hasletter)
        {
                n=0;
                for (y=0;y&lt;length;y++)
                {
                    if (n&lt;length){
                        words[x][y]=words[i][n];
                        n++;
                    }
                    else{
                        words[x][y]='*';
                    }
                }
                x++;
                counter++;


        }


    }

}

void printresults(){
    for (i=0;i&lt;counter;i++){
        for (n=0;n&lt;length;n++){
            cout&lt;&lt;words[i][n];
        }

        cout&lt;&lt;endl;
    }
}

void printlast(){
    cout&lt;&lt;"your word is: ";
    for (n=0;n&lt;length;n++){
                cout&lt;&lt;words[0][n];
            }
    cout&lt;&lt;endl;
}

int main() {
    bool found(false);
    int guesslimit,random;
    cout&lt;&lt;"how many guesses can I have?"&lt;&lt;endl;
    cin&gt;&gt;guesslimit;
    beginning:
    initarray();
    selectlength();
    while (!found){
        //cout&lt;&lt;x&lt;&lt;endl;
        mostletters();
        guessmost();
        letterguess();
        if (letterans=='r'){
            goto beginning;
        }
        if (letters[1][yescount]==0){
            cout&lt;&lt;"no words match"&lt;&lt;endl;
            break;
        }
        if (yesletter){
            yesguess();
            extraletters();
        }
        if(!yesletter &amp;&amp; !alreadyguess){
            noguess();
        }
        //printresults();
        if (mastercount&gt;26){
            break;
            cout&lt;&lt;"hey"&lt;&lt;endl;
        }
        if (counter==1){
            printlast();
            found=true;
        }
        if(counter&gt;1 &amp;&amp; !alreadyguess){
            cout&lt;&lt;guesses&lt;&lt;" guesses so far"&lt;&lt;endl;
        }
        if (guesses==guesslimit){
            cout&lt;&lt;"there are "&lt;&lt;counter&lt;&lt;" words left"&lt;&lt;endl;
            printresults();
            srand(time(NULL));
            cout&lt;&lt;"my guess is: ";
            random=rand()%counter+1;
            for (n=0;n&lt;length;n++){
                cout&lt;&lt;words[random][n];
            }
            break;
        }

    }
}
</code></pre>
