This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

why sprintf can't convert int ??

main()
{
char szOut[100];
int nYear,nMonth,nDate,nHour,nMinute,nSecond,nOldSec = 0;

rtc_init();
set_date_time(2005,6,3,10,58,55);
while(1)
{
get_date_time(&nYear,&nMonth,&nDate,&nHour,&nMinute,&nSecond);
memset(szOut,0,sizeof(szOut));
if (nOldSec != nSecond)
{
nOldSec = nSecond;
goto_xy(1,0);
memset(szOut,0,sizeof(szOut));
sprintf(szOut,"%04d/%02d/%02d %02d:%02d:%02d",nYear,nMonth,nDate,nHour,nMinute,nSecond);
printf(szOut);
}
}

date time from rtc is ok,but sprintf sometimes ok sometime error(printf result is "2005/06/03 32423423/59/02","2005/06/03 10/324234/384083" ).I selected the ups3354dv from the device database.
please help me? thanks.

0