reading file into a char array and then calculating strlen gets stuck in C++
<p>I have the following C program</p>

<pre><code>f = fopen("input", "r");
char line[1024];
while ((fgets(line, 1024, f)) != NULL) {
    cout &lt;&lt; strlen(line) &lt;&lt; endl;
    exit(1);//just to see what went wrong.
}
fclose(f);
</code></pre>

<p>It looks like it will get stuck when evaluating <code>strlen(line)</code>. But it seems strange to me, since I checked individual characters of line, and I found <code>line[3]=='\0'</code>. So why would it be non-stopping?</p>
