]> zdv2.bktei.com Git - BK-2023-05.git/blob - src/kr_exercises/ch1/s1.5/getchar_eof_test.c
update(src/kr):Finish section 1.5.1
[BK-2023-05.git] / src / kr_exercises / ch1 / s1.5 / getchar_eof_test.c
1 /* Desc: Test behavior of "getchar() not equal to EOF"
2 * Usage: name=getchar_eof_test; gcc -o "$name" "$name".c; ./"$name";
3 * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.5.1
4 */
5 #include <stdio.h>
6
7 /* Reads a single character. Will display "output:0" if first
8 * character provided is EOF (e.g. "alt+D"). Otherwise, will display
9 * "output:1".
10 */
11
12 int main(){
13 int output;
14 output = (getchar() != EOF);
15 printf("output:%d", output);
16 return 0;
17 };
18
19 /* Author: Steven Baltakatei Sandoval
20 * License: GPLv3+
21 */