Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdarg.h>
- void printInfo(char* format, ...);
- void printError(char* format, ...);
- void printInfo(char* format, ...)
- {
- va_list args;
- va_start(args, format);
- printf("INFO: ");
- vprintf(format, args);
- va_end(args);
- }
- void printError(char* format, ...)
- {
- va_list args;
- va_start(args, format);
- printf("ERROR: ");
- vprintf(format, args);
- va_end(args);
- }
- int main (int argc, char **argv){
- printInfo("%c\n", 'C');
- printInfo("Test, %d %c %s\n", 123, 'C', "String");
- printInfo("without arguments\n");
- printError("String %d %c %s\n", 123, 'C', "testing string");
- return 0;
- }
- /*
- output:
- INFO: C
- INFO: Test, 123 C String
- INFO: without arguments
- ERROR: String 123 C testing string
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement