aboutsummaryrefslogtreecommitdiff
path: root/1/6.c
blob: e1e40c1640a833b8846d98a2d503e219fb4059e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 <stdio.h>

int main () {
	int c;
	while ((c=getchar())!=EOF) {
		printf("%d ", c!=EOF);	/* while input */
	}	printf("%d ", c!=EOF);	/* on input end */
}