User manual
MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 352 2012 Microchip Technology Inc.
Example
printf("Total = %4d%", 23);
yields ’Total = 23%’
printf("Size is %lx", size);
where size is a long, prints size as hexadecimal.
printf("Name = %.8s", "a1234567890");
yields ’Name = a1234567’
printf("xx%*d", 3, 4);
yields ’xx 4’
/* vprintf example */
#include <stdio.h>
int
error (char * s, ...)
{
va_list ap;
va_start(ap, s);
printf("Error: ");
vprintf(s, ap);
putchar(’\n’);
va_end(ap);
}
void
main (void)
{
int i;
i = 3;
error("testing 1 2 %d", i);
}
See Also
sprintf()
Return Value
The printf() and vprintf() functions return the number of characters written to
stdout.
PUTCH
Synopsis
#include <conio.h>
void putch (char c)
Description
The putch() function is provided as an empty stub which can be completed as each
project requires. Typically this function will accept one byte of data and send this to a
peripheral which is associated with stdout.