Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdarg.h>
- void myprintf(const char *, ...);
- void myprintf(const char *fmt, ...)
- {
- va_list args; //this is actually just a placeholder to our first (variable) argument
- va_start(args, fmt); //set up our list so we can retrieve it
- while (*fmt) //loop through each character of the string
- {
- if (*fmt++ == '%') //our control character
- { //we increment it as well so our next character is our type spec
- switch (*fmt++) //case-select our list, and increment it as well.
- {
- case 'i': //integer
- break;
- case 'u': //unsigned int
- break;
- case 's': //string
- break;
- }
- }
- }
- va_end(args);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement