diff options
author | zakk <zakk@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-08-26 17:39:27 +0000 |
---|---|---|
committer | zakk <zakk@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-08-26 17:39:27 +0000 |
commit | 6bf20c78f5b69d40bcc4931df93d29198435ab67 (patch) | |
tree | e3eda937a05d7db42de725b7013bd0344b987f34 /lcc/tst/stdarg.c | |
parent | 872d4d7f55af706737ffb361bb76ad13e7496770 (diff) | |
download | ioquake3-aero-6bf20c78f5b69d40bcc4931df93d29198435ab67.tar.gz ioquake3-aero-6bf20c78f5b69d40bcc4931df93d29198435ab67.zip |
newlines fixed
git-svn-id: svn://svn.icculus.org/quake3/trunk@6 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'lcc/tst/stdarg.c')
-rwxr-xr-x | lcc/tst/stdarg.c | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/lcc/tst/stdarg.c b/lcc/tst/stdarg.c index ff6c918..c6a5338 100755 --- a/lcc/tst/stdarg.c +++ b/lcc/tst/stdarg.c @@ -1,51 +1,51 @@ -#include <stdarg.h>
-
-struct node { int a[4]; } x = {1,2,3,4};
-
-print(char *fmt, ...);
-
-main() {
- print("test 1\n");
- print("test %s\n", "2");
- print("test %d%c", 3, '\n');
- print("%s%s %w%c", "te", "st", 4, '\n');
- print("%s%s %f%c", "te", "st", 5.0, '\n');
- print("%b %b %b %b %b %b\n", x, x, x, x, x, x);
- return 0;
-}
-
-print(char *fmt, ...) {
- va_list ap;
-
- va_start(ap, fmt);
- for (; *fmt; fmt++)
- if (*fmt == '%')
- switch (*++fmt) {
- case 'b': {
- struct node x = va_arg(ap, struct node);
- printf("{%d %d %d %d}", x.a[0], x.a[1], x.a[2], x.a[3]);
- break;
- }
- case 'c':
- printf("%c", va_arg(ap, char));
- break;
- case 'd':
- printf("%d", va_arg(ap, int));
- break;
- case 'w':
- printf("%x", va_arg(ap, short));
- break;
- case 's':
- printf("%s", va_arg(ap, char *));
- break;
- case 'f':
- printf("%f", va_arg(ap, double));
- break;
- default:
- printf("%c", *fmt);
- break;
- }
- else
- printf("%c", *fmt);
- va_end(ap);
-}
+#include <stdarg.h> + +struct node { int a[4]; } x = {1,2,3,4}; + +print(char *fmt, ...); + +main() { + print("test 1\n"); + print("test %s\n", "2"); + print("test %d%c", 3, '\n'); + print("%s%s %w%c", "te", "st", 4, '\n'); + print("%s%s %f%c", "te", "st", 5.0, '\n'); + print("%b %b %b %b %b %b\n", x, x, x, x, x, x); + return 0; +} + +print(char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + for (; *fmt; fmt++) + if (*fmt == '%') + switch (*++fmt) { + case 'b': { + struct node x = va_arg(ap, struct node); + printf("{%d %d %d %d}", x.a[0], x.a[1], x.a[2], x.a[3]); + break; + } + case 'c': + printf("%c", va_arg(ap, char)); + break; + case 'd': + printf("%d", va_arg(ap, int)); + break; + case 'w': + printf("%x", va_arg(ap, short)); + break; + case 's': + printf("%s", va_arg(ap, char *)); + break; + case 'f': + printf("%f", va_arg(ap, double)); + break; + default: + printf("%c", *fmt); + break; + } + else + printf("%c", *fmt); + va_end(ap); +} |