I'm not sure about Codevisions printf function, but in general printf is formated printing. It uses putc, which directs the output stream to whatever you want. If your putc function is directed at an LCD, this is where it will show up. If it is directed at the serial port then sent to a PC, you can view the stream with a terminal program, etc.
Here is a simple example of a printf function with no strings and no floating point:
Code:
/*-----------------28.08.99 22:49-------------------
* Simple printf function (no fp, and strings)
*--------------------------------------------------*/
int printf(const char *format, ...) {
static const char hex[] = "0123456789ABCDEF";
char format_flag;
unsigned int u_val, div_val, base;
char *ptr;
va_list ap;
va_start (ap, format);
for (;;) {
while ((format_flag = *format++) != '%') { // Until '%' or '\0'
if (!format_flag) {
va_end (ap);
return (0);
}
lcd_putch (format_flag);
}
switch (format_flag = *format++) {
case 'c': format_flag = va_arg(ap,int);
default: lcd_putch(format_flag); continue;
case 'd': base = 10; div_val = 10000; goto CONVERSION_LOOP;
case 'x': base = 16; div_val = 0x10;
CONVERSION_LOOP:
u_val = va_arg(ap,int);
if (format_flag == 'd') {
if (((int)u_val) < 0) {
u_val = - u_val;
lcd_putch ('-');
}
while (div_val > 1 && div_val > u_val) div_val /= 10;
}
do {
lcd_putch (hex[u_val / div_val]);
u_val %= div_val;
div_val /= base;
} while (div_val);
}