/*
函数名:
vsprintf
功 能:
送格式化输出到串中
用 法:
int vsprintf(char *string, char *format, va_list param);
程序例:
*/
#include
<stdarg.h>
char
buffer[80];
int
vspf(char *fmt, ...)
{
va_list argptr;
int cnt;
va_start(argptr, fmt);
cnt = vsprintf(buffer, fmt,
argptr);
va_end(argptr);
return(cnt);
}
int
main(void)
{
int inumber = 30;
float fnumber = 90.0;
char string[4] = "abc";
vspf("%d %f %s",
inumber, fnumber, string);
printf("%s\n",
buffer);
return 0;
}
/*
函数名:
uart_printf
功 能:
送格式化输出到串口
用 法:
int uart_printf(char *format, ...);
程序例:
*/
int
uart_printf(const char *fmt, ...)
{
va_list
arg;
int
cnt;
char
buffer[80];
va_start(arg,
fmt);
cnt
= vsprintf(buffer, fmt, arg);
va_end(arg);
UART0_SendBuf(buffer);
// Send out through UART0
return
cnt;
}
int
main(void)
{
uint8
c = 0xFF;
uart_printf("Hello
c=0x%04X\n", c);
return
0;
}
|
tengjingshu_112148725 2009-7-22 11:39