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 support@ccsinfo.com

printf with arrays

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








printf with arrays
PostPosted: Sat Feb 28, 2009 7:27 pm     Reply with quote

I'm trying to use printf to print a series of array data to my LCD but it won't compile. I keep getting this error: "Printf variable count (%) does not match actual count" My compiler is PCM 4.086.

Here is my code:
Code:

// parameters
int16 pv[5];           // current temperature 0-500   

void main()
{
lcd_init();

pv[0]=200;
pv[1]=202;
pv[2]=204;
pv[3]=206;
pv[4]=208;

printf(lcd_putc, "\f%s %s %s %s %s",   "TNK",   "HS1",   "GN1",   "HS2",    "GN2");
printf(lcd_putc, "\n%u %u %u %u %u", pv[0], pv[1], pv[2], pv[3], pv[4]);


I have also tried this with the same result:
Code:

printf(lcd_putc, "\n%u %u %u %u %u", *(pv), *(pv+1), *(pv+2), *(pv+3), *(pv+4));


Any tips on how to do this?
future_
Guest







PostPosted: Sat Feb 28, 2009 8:01 pm     Reply with quote

What I can see is that you are trying to print longs with %u, you should use %Lu.
Guest








PostPosted: Sat Feb 28, 2009 8:40 pm     Reply with quote

That fixed it. The compiler must have been trying to tell me in a roundabout way that I had the wrong number of bytes.

I stared and stared and couldn't see my mistake. I'm not used to 8 bit integers and 16 bit longs yet.

Many Thanks...
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