1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-29 01:21:07 +02:00

Edit getchar() notes.

This commit is contained in:
Levi Bostian
2013-09-20 22:37:40 -05:00
parent 67cd987efa
commit 981cc871a4

View File

@@ -453,15 +453,14 @@ void str_reverse(char *str_in)
///////////////////////////////////// /////////////////////////////////////
// Built in functions: // Built in functions:
///////////////////////////////////// /////////////////////////////////////
// from stdio.h: // from: #include <stdio.h>
// getchar() // ** getchar() **
int c = getchar(); //reads character from input. // int c = getchar(); //reads character from input.
// If input = hi, 'h' is returned then next call, 'i' returned. // If input = hi, 'h' is returned then next call, 'i' returned.
while ((c = getchar()) != EOF) { // EOF constant "end of file". while ((c = getchar()) != EOF) { // EOF constant "end of file".
// Linux: CTRL+D, Windows: CTRL+X // Linux: CTRL+D, Windows: CTRL+X
// must have () around getchar() as != is run before =. // must have () around getchar() as != is run before =.
putchar(c); //prints character (without newline at end) putchar(c); //prints character (without newline at end)
char c = getchar();
} }
//if referring to external variables outside function, must use extern keyword. //if referring to external variables outside function, must use extern keyword.