Image

Imagevalera wrote in Imagecpp

hi, i have been playing with this code, and it's supposed to terminate on EOF, but i can't seem to figure out when exactly that... happens?
when i press enter, it just goes to the next line. the only way to terminate is through ^C, but that way it obviously doesn't give the line count.
i'm using cc to compile and am running this through ssh on my linux box.
code:
#include 
[Error: Irreparable invalid markup ('<stdio.h>') in entry. Owner must fix manually. Raw contents below.]

hi, i have been playing with this code, and it's supposed to terminate on EOF, but i can't seem to figure out when exactly that... happens?
when i press enter, it just goes to the next line. the only way to terminate is through ^C, but that way it obviously doesn't give the line count.
i'm using <code>cc</code> to compile and am running this through ssh on my linux box.
code:
<pre style="padding:5px; margin-left: 20px; border: dashed 1px #333; font-size: 12px;">#include <stdio.h>

// count inputted characters
main (){
double nc; //number of characters

for(nc=0;getchar()!=EOF; ++nc)
;

printf("%.0f\n", nc); //after the loop finishes, print the number of inputted characters
}
</pre>

any ideas of why it's not terminating on new line? does EOF work in some other way?