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

problem with printf and const

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 18, 2008 11:57 am     Reply with quote

Quote:

char const otra[3][*]={
"Weight=%u Kg",
"Height= %u cm",
"Age= %u years"
};

void main(){

// Init LCD
....

printf(lcd_putc, otra[1], 185);

the message than I see in LCD is:

"Weight= %u Kg Height=185 cm"

You need to understand something about CCS. It's intended for small
embedded microcontroller chips, so because of that, the compiled code
is designed to be small.

Your example is based on the belief that CCS has a large run-time
module (such as MSCRT.DLL) that contains the entire printf parsing
mechanism. But it does not.

You are trying to pass the format string to printf at run-time. But CCS
doesn't parse the format string at run-time. It parses it at compile-time,
and creates a small, compact, specific code to handle the "%u" only.
If you also put in "%f", then it creates code for that too. But it's all
created at compile-time. It's hard-coded.
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