summaryrefslogtreecommitdiff
path: root/ch2
diff options
context:
space:
mode:
authorAdam Carpenter <gitlab@53hor.net>2019-07-23 12:37:01 -0400
committerAdam Carpenter <gitlab@53hor.net>2019-07-23 12:37:01 -0400
commit8560bf95251098184ab4dfcf11a39d0954105235 (patch)
treeeba69a737216b054796c77be94e4946a1c659249 /ch2
parent552bc70b77d4fca54929b46190128721b93d887c (diff)
downloadlearning-c-8560bf95251098184ab4dfcf11a39d0954105235.tar.xz
learning-c-8560bf95251098184ab4dfcf11a39d0954105235.zip
Finished 2-10.
Diffstat (limited to 'ch2')
-rw-r--r--ch2/2-10.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ch2/2-10.c b/ch2/2-10.c
index e69de29..619e2d1 100644
--- a/ch2/2-10.c
+++ b/ch2/2-10.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+#define MAX_LEN 20
+
+void lower(char* source, char* dest);
+
+int main() {
+ char* s = "This Is A Test.";
+ char lower_s[MAX_LEN];
+ lower(s, lower_s);
+ printf("%s -> %s\n", s, lower_s);
+ return 0;
+}
+
+void lower(char* source, char* dest) {
+ int i;
+
+ for (i = 0; source[i] != '\0'; i++)
+ dest[i] = source[i] >= 'A' && source[i] <= 'Z' ? source[i] - 'A' + 'a' : source[i];
+
+ dest[i] = '\0';
+}