Advertisement
Guest User

Untitled

a guest
Oct 9th, 2016
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdarg.h>
  2.  
  3. void myprintf(const char *, ...);
  4.  
  5. void myprintf(const char *fmt, ...)
  6. {
  7.     va_list args; //this is actually just a placeholder to our first (variable) argument
  8.     va_start(args, fmt); //set up our list so we can retrieve it
  9.     while (*fmt) //loop through each character of the string
  10.     {
  11.         if (*fmt++ == '%') //our control character
  12.         {                              //we increment it as well so our next character is our type spec
  13.             switch (*fmt++) //case-select our list, and increment it as well.
  14.             {
  15.              case 'i': //integer
  16.                  break;
  17.              case 'u': //unsigned int
  18.                  break;
  19.              case 's': //string
  20.                  break;
  21.             }
  22.         }
  23.     }
  24.     va_end(args);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement