像 printf 這類的 function 是怎麼寫的呢?
int /* O - Number of bytes written */
my_Printf(const char *message, /* I - Message string to use */
...) /* I - Additional arguments as needed */
{
int bytes; /* Number of bytes formatted */
va_list ap; /* Pointer to additional arguments */
va_start(ap, message);
printf("my printf() : ");
bytes = vprintf(message, ap);
va_end(ap);
return bytes;
}
void main(){
int i=5;
my_Printf("my number : %d\n", i);
}
沒有留言:
張貼留言