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

truncating a string using printf (PCD 4.099)

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







truncating a string using printf (PCD 4.099)
PostPosted: Thu Feb 04, 2010 2:52 pm     Reply with quote

hi there

I'm trying to just print a set number of characters instead of the whole string. According to this printf reference, I would do something like printf("%0.5s", example_string); to truncate it to 5 chars.

http://www.thinkage.ca/english/gcos/expl/b/lib/printf.html

I can't seem to get this to work though - it doesn't make any difference. Any ideas? Is this a known limitation of the compiler?

Many thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 04, 2010 3:01 pm     Reply with quote

Post a very short (but compilable) test program that shows what you
have done. See this thread for an example of a test program for
floating point printf problems:
http://www.ccsinfo.com/forum/viewtopic.php?t=39954
Ttelmah
Guest







PostPosted: Thu Feb 04, 2010 3:43 pm     Reply with quote

I'd say it was a limitation.
Quite a few of the 'extended' printf abilities don't work in CCS. Things like left justification for example.
I'd just use the strncpy fuction to transfer the number of characters wanted, before printing.

Best Wishes
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