[讨论]Keil,那位大侠用过vsprintf函数?好像有问题呀!
我的程序如下,在BC3。0下测试是好的,可是在KEIL下好像有问题。我的程序下载在板子上
也有问题,用keil来debug仿真也看出来有问题。请各位高手解答!
谢谢!
#include <stdio.h>
#include <stdarg.h>
//#define _EMU_ // bc3.0 build use
#ifdef _EMU_
#define code const
#define xdata
#endif
void FormatData( char* pszGetData,const char* pszFormat,... )
{
va_list ap;
va_start( ap, pszFormat );
vsprintf( pszGetData, pszFormat, ap );
va_end( ap );
}
void main( void )
{
code unsigned char bTestData[] = {
0x00,0x11,0x22,0x33,0x44,0x55 };
unsigned int nIntData;
code char* pszStr = "This is a
TEST!";
xdata char szTestBuf[1024+1];
while( 1 )
{
// after this,The szTestBuf data is not "Get HEX IS: 00
11 22 33 44 55",Why?
FormatData( szTestBuf,"Get HEX IS: %02x %02x %02x %02x %
02x %02x",
bTestData[0],bTestData[1],bTestData[2],bTestData
[3],bTestData[4],bTestData[5] );
#ifdef _EMU_
printf( "\n%s\n",szTestBuf );
#endif
nIntData = 12345;
FormatData( szTestBuf,"Get INT is: %d Get string is: %
s",nIntData,pszStr );
#ifdef _EMU_
printf( "%s",szTestBuf );
break;
#endif
}
}
发表时间:2003年7月4日10:17:49