summaryrefslogtreecommitdiff
path: root/21_read_rec1/test.c
diff options
context:
space:
mode:
authorHaidong Ji2022-04-15 15:51:30 -0500
committerHaidong Ji2022-04-15 15:51:30 -0500
commit442a49ad5a48d417345959b903ae6a6d32d55759 (patch)
treec7127bb497e5e439018b1915e0136eec2c9cb124 /21_read_rec1/test.c
Great C programming funHEADmaster
Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git
Diffstat (limited to '21_read_rec1/test.c')
-rw-r--r--21_read_rec1/test.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/21_read_rec1/test.c b/21_read_rec1/test.c
new file mode 100644
index 0000000..52fd4e4
--- /dev/null
+++ b/21_read_rec1/test.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void printDigits(int x) {
+ if (x == 0) {
+ printf("0");
+ }
+ else if (x < 0) {
+ printf("-");
+ printDigits(-x);
+ }
+ else {
+ int a = x/10;
+ int b = x %10;
+ printf("a=%d, b=%d\n",a,b);
+ if (a != 0) {
+ printDigits(a);
+ }
+ printf("%d",b);
+ }
+}
+
+
+int main(void) {
+ printDigits(297);
+ printf("\n");
+ return EXIT_SUCCESS;
+}