Reading char from file in c++
<p>I have created a file hangman_word_collection.txt and stored all the content of file into the string line.</p>

<p>Now I want to use the line string in my program but <code>line[0]</code> is not having any value into it or I don't know if it have something in it.</p>

<p>I am new to this please help.</p>

<p>Here is the code:</p>

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

using namespace std;

int main() {
string line;

ifstream myfile ("hangman_word_collection.txt");
if (myfile.is_open()) {
    while (myfile.good()) {
        getline (myfile,line);
        cout &lt;&lt; line &lt;&lt; endl;
    }
}
for(int i=0; i &lt;= 79; i++) {
    cout &lt;&lt; "\n" &lt;&lt; i;
    cout &lt;&lt; ":" &lt;&lt; line[i];
}
return 0;
}
</code></pre>

<p>And the output:</p>

<pre class="lang-none prettyprint-override"><code>actingraringbackupcampusdacoiteasilyfabricgardenhackediceboxprimeralwaysupload.


0:
1:c
2:t
3:i
4:n
5:g
6:r
7:a
8:r
9:i
10:n
11:g
12:b
13:a
14:c
15:k
Press &lt;RETURN&gt; to close this window...
</code></pre>
