8051 >> HI-TECH C PRO for the Silicon Labs 8051 MCU Family

Pages: 1
pavan01
Tester
***

Reged: Apr 11 2008
Posts: 15
Loc: India
unable to use sprintf()
      #57862 - Fri May 23 2008 05:35 AM

when compile a simple c program with sprintf().
There is a warning msg
main.c: main()
16: sprintf(g_byBuff,"%d",g_byTemp);
^ (359) illegal conversion between pointer types (warning)

And the program is

#include <stdio.h>
xdata unsigned char g_byTemp;
xdata unsigned char g_byBuff[20];
xdata unsigned char g_byBuffr[] = "Hello ";
xdata unsigned char* _ptemp;
xdata unsigned char g_byindex;
void main(void)
{
g_byTemp = 0;
_ptemp = 0;
_ptemp = &g_byTemp;
while (1)
{
g_byTemp++;
sprintf(g_byBuff,"%d",g_byTemp);
for (g_byindex = 0;g_byindex < 10;g_byindex++)
{
g_byBuff[g_byindex] = g_byBuffr[g_byindex];
}
}
}
with command line


Post Extras: Print Post   Remind Me!   Notify Moderator  
Dan Henry
Guru
****

Reged: Oct 16 2003
Posts: 3387
Loc: Boulder, Colorado U.S.A.
Re: unable to use sprintf() [Re: pavan01]
      #57962 - Fri May 23 2008 02:18 PM

Please use Code tags to maintain formatting and improve code readability.

If you remove the 'xdata' qualifier from everything and let the PRO compiler figure out where to put things, then it works, doesn't it?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 2 anonymous users are browsing this forum.

Moderator:  Andrew L, clyde, Brent W, jeff, dave g, meisty, josh stevo 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 627

Rate this topic

Jump to

Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5