summaryrefslogtreecommitdiffhomepage
path: root/c.html.markdown
diff options
context:
space:
mode:
authorLevi Bostian <levi.bostian@gmail.com>2013-08-31 12:50:58 -0500
committerLevi Bostian <levi.bostian@gmail.com>2013-08-31 12:50:58 -0500
commitdba7ec8b9643f693bdb023f9827999b2b14d008b (patch)
tree9af414ae00306668d9c69838acf117557d7a3547 /c.html.markdown
parente03cda583dd6127831a32fcc8bd8cd8b53399794 (diff)
Add getchar(), putchar(), EOF to C
Diffstat (limited to 'c.html.markdown')
-rw-r--r--c.html.markdown10
1 files changed, 10 insertions, 0 deletions
diff --git a/c.html.markdown b/c.html.markdown
index 4e1e1e56..7010b9d5 100644
--- a/c.html.markdown
+++ b/c.html.markdown
@@ -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);