From: Cian Bagshaw Date: Sun, 4 Dec 2022 12:42:31 +0000 (+0000) Subject: Added exercise 1-6 X-Git-Url: https://tests.cianb.xyz/?a=commitdiff_plain;h=2f5609430f4174c32180975bf86c1b79eba0d0c9;p=cProgLang Added exercise 1-6 --- diff --git a/1/6.c b/1/6.c new file mode 100644 index 0000000..e1e40c1 --- /dev/null +++ b/1/6.c @@ -0,0 +1,17 @@ +/* + Exercise 1-6. Verify that the expression getchar() != EOF is 0 or 1. + === + + Each character typed returned a 1, until I typed Ctrl+d, to signify the end of + input, which yielded a 0. Therefor, getchar()!=EOF is 1 with all characters and + 0 a the end of input/file. Thus, it always equals 0 or 1. +*/ + +#include + +int main () { + int c; + while ((c=getchar())!=EOF) { + printf("%d ", c!=EOF); /* while input */ + } printf("%d ", c!=EOF); /* on input end */ +}