C++ reading file into char* array
<p>I have a trouble reading a .txt file into a char* array.</p>

<p>I have a levels.txt file that looks like this:</p>

<pre><code>level1.txt
level2.txt
</code></pre>

<p>I have my array defined inside a class as</p>

<pre><code> char* levels[10];
</code></pre>

<p>And my parsing function looks like this:</p>

<pre><code>// Parse the level list file
int Environment::parseLevels() {
    ifstream data;
    data.open("levels.txt");

    char buf[64];

    for (int i=0; i&lt;sizeof(levels); i++) {
        data.getline(buf, 64);
        levels[0] = strtok(buf, " ");
    }
}
</code></pre>

<p>If I do <em>cout &lt;&lt; levels[0];</em> right after</p>

<pre><code>levels[0] = strtok(buf, " ");
</code></pre>

<p>then I get a fine output. However, when I try to <em>cout &lt;&lt; levels[0];</em> from somewhere else, nothing gets displayed.</p>

<p>What am I doing wrong?</p>

<p>Thank you in advance!</p>
