aboutsummaryrefslogtreecommitdiff
path: root/tst/va_test.c
diff options
context:
space:
mode:
authorbeber <beber>2005-12-06 15:48:53 +0000
committerbeber <beber>2005-12-06 15:48:53 +0000
commitc61f1a44f1754dea185541e556f1091838aec693 (patch)
tree5fa8a72d7ef9486673b051ac2e7b6adeffa90d6b /tst/va_test.c
parentAdd ebuild (diff)
downloadespik-c61f1a44f1754dea185541e556f1091838aec693.tar.xz
start a function for debug printf
Diffstat (limited to '')
-rw-r--r--tst/va_test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tst/va_test.c b/tst/va_test.c
new file mode 100644
index 0000000..d92e1aa
--- /dev/null
+++ b/tst/va_test.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+void espik_debug_print (char *fct, ...)
+{
+ va_list ap;
+ char c, *s;
+ int d, e;
+
+ va_start (ap, fct);
+ printf("fct : %s\n", *(fct+1));
+ while (*fct)
+ {
+// fprintf (stderr, ">fct : %c\n", *(fct+1));
+ switch (*fct++)
+ {
+ case 's': s = va_arg (ap, char*);
+ fprintf (stderr, "%s", s);
+ break;
+ case 'd': d = va_arg (ap, int);
+ fprintf (stderr, "%d", d);
+ break;
+ default :
+// case 'c':
+ e = va_arg (ap, int);
+ fprintf (stderr, "%c", (char)e);
+ break;
+// default : fprintf (stderr, "Unknown type : %c\n", *fct);
+ }
+ // fprintf (stderr, "<fct : %c\n", *fct);
+ }
+ fprintf (stderr, "\n");
+
+ va_end (ap);
+}
+
+int main()
+{
+ int a = 10;
+ char b = 'c';
+ char c[] = "totomadit";
+
+ espik_debug_print ("a : %d\n", a);
+
+ return (0);
+}