codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <stdio.h> #include <stdarg.h> void debugf_int(const char *file, unsigned int line, const char *format, ...) { static char buf[8192]; va_list args; va_start(args, format); vsnprintf(buf, sizeof(buf)-1, format, args); va_end(args); fprintf(stderr, "debug: %s:%u: %s\n", file, line, buf); fflush(stderr); } #define debugf(f,...) debugf_int(__FILE__, __LINE__, f, ##__VA_ARGS__) int main() { debugf("Hello, world!"); debugf("This is an integer: %d", 5); debugf("Here's more: %d, %.1f, \"%s\"", 42, 2.3f, "Hi!"); return 0; }
Private
[
?
]
Run code
Submit