CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

bug in sprintf with int32 (version 3.212)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Will Reeve



Joined: 30 Oct 2003
Posts: 209
Location: Norfolk, England

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

bug in sprintf with int32 (version 3.212)
PostPosted: Mon Oct 18, 2004 8:00 am     Reply with quote

Can someone please confirm this:

The following lines of code don't appear to do what it should!
Code:
int32 sdisplay;
sdisplay = 10000; // manually set pdisplay variable for de-bug
sprintf(line1,"S%04lu",sdisplay);


For values of sdisplay 0 to 9999 the resultant string is correct (i.e. S0000 to S9999) however if sdisplay is 10000 then the string generated by sprintf is S10000 even though I have restricted it to 4 characters (it should be S0000)

The restriction doesn't appear to work for int32 length? Changing sdisplay to a int16 works OK.
Guest








PostPosted: Mon Oct 18, 2004 8:40 pm     Reply with quote

confirmed.

well, not a serious bug, might call it a CCS's non-ANSI feature ? Laughing

workaround: sprintf(line1,"S%04lu", (int16) sdisplay);
Will Reeve



Joined: 30 Oct 2003
Posts: 209
Location: Norfolk, England

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Tue Oct 19, 2004 2:29 am     Reply with quote

I ended up casting it into another int16 local as I have been programmed a long time ago (mainly a nasty little H8 complier to be honest) not to try and do �clever� things like a cast inside a function call but having just tried it, it works fine!

It�s always nice to fine a bug (human nature I guess!). There is a nasty one in the PCW IDE. I usually shoot off and do other things like check email etc. while the PIC is being programmed in the debugger; �attached� as it were. Yesterday I thought I would select �Help > Contents� to have a look at some help files� don�t do this while the IDE is downloading code to the PIC it crashes badly!

To be honest with you the current development systems by CCS is actually very stable and a joy to use. The support guys are good and always fix things quickly (even when it�s my fault!). I also code windows in Delphi and Borland could learn a few tricks from CCS IMHO.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group