Running C — helloWorld runs but nothing else — Ubuntu

Well this will run until EOF is detected.
EOF can be ‘inserted’ pressing ctrl+D in Linux terminal.
It works OK then.

change while ((c = getchar()) != EOF) to while ((c = getchar()) != '\n') and it will only ask you for one line of input and then return the result.

btw: main is of type int and should return a value.

Leave a Comment