|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
printf with arrays |
Posted: Sat Feb 28, 2009 7:27 pm |
|
|
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
|
|
Posted: Sat Feb 28, 2009 8:01 pm |
|
|
What I can see is that you are trying to print longs with %u, you should use %Lu. |
|
|
Guest
|
|
Posted: Sat Feb 28, 2009 8:40 pm |
|
|
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... |
|
|
|
|
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
|