mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Add getchar(), putchar(), EOF to C
This commit is contained in:
parent
e03cda583d
commit
dba7ec8b96
@ -427,6 +427,16 @@ void str_reverse(char *str_in)
|
||||
}
|
||||
}
|
||||
|
||||
// Built in functions:
|
||||
// from stdio.h:
|
||||
int c = getchar(); //reads character from user. If user types hello, only h is read.
|
||||
// getchar() can be stored into int or char. I am using int because char is not large
|
||||
// enough to store EOF used below.
|
||||
while (c != EOF) { // EOF is value for "end of file". Linux: CTRL+D, Windows: CTRL+X
|
||||
putchar(c); //prints character (without newline at end)
|
||||
char c = getchar();
|
||||
}
|
||||
|
||||
/*
|
||||
char c[] = "This is a test.";
|
||||
str_reverse(c);
|
||||
|
Loading…
Reference in New Issue
Block a user