c++ for loop is being skipped
<p>What am I doing wrong with this small program.</p>

<p>I'm just starting to learn c++, and by all mean I can accept this as a moot question. I'm reading through the Prata c++ primer and it gave me a code example which takes a char array and uses strcmp() in a for loop which iterates sequentially through the ASCII code starting with '?' until a test char variable ==s a set value from another char.</p>

<p>Thinking I could outdo the book I tried to create a similar program which takes a char array and using a for loop will take a test char array and iterate through each value of the array until the two variables are equal.</p>

<p>I simplified the program to only take the first of each array in the for loop because I was experiencing a problem where the program seems to simply skip over the for loop and terminate. </p>

<p>Below are first the prata code snippet, followed by my piece of code. Any feedback (even abusive >_&lt;) would be useful.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;cstring&gt;

int main() {
using namespace std;
char word[5] = "?ate";

for (char ch = ‘a’; strcmp(word, "mate"); ch++) {
cout &lt;&lt; word &lt;&lt; endl;
word[0] = ch;
}

cout &lt;&lt; "After loop ends, word is " &lt;&lt; word &lt;&lt; endl;
return 0;
}
</code></pre>

<p>My code (though maybe poorly done, I can accept that)</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;cstring&gt;

int main() {
    using namespace std;
    char word[5] = "word";
    char test[5] = "????";
    int j = 0;
    int i = 0;

    cout &lt;&lt; "word is " &lt;&lt; word &lt;&lt; "\nTest is " &lt;&lt; test &lt;&lt; endl;
    cout &lt;&lt; word[0] &lt;&lt; " " &lt;&lt; test[0] &lt;&lt; endl;
    for (char temp = '?'; word[0] == test[0] || temp == 'z'; temp++) {
        if ((word[i]) == (test[j])) {
            test[j] = temp;
            j++;
            temp = '?';
        }
        test[j] = temp++;
        cout &lt;&lt; test &lt;&lt; endl; //Added to see if the for loop runs through once, 
                                  //which is does not
    }
    return 0;
}
</code></pre>
