|
|
View previous topic :: View next topic |
Author |
Message |
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
how to use printf(); function |
Posted: Wed May 16, 2007 4:00 am |
|
|
Dear sir,
here i am using 16f913, MPLAB 7.5 Ver. & CCS PCM C Compiler, Version 3.249, 34534
here i am writing driver for glass lcd 5.1 digits.
i read the ex_92lcd.c,but i am not understand the,
Code: | printf(lcd_putc,"\f%4lu",number);
|
in void lcd_putc function the received value is
here how the value is passed to this function,
plz explain me this function clearly & printf(); function. _________________ Thank You,
With Best Regards,
Deepak. |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Wed May 16, 2007 7:31 am |
|
|
printf() in CCS doesn't work exactly like printf() in K&R as it can take the name of a function as its first parameter. That function must accept a character. As the printf() function walks it way through the printable string, it sends it one character at a time to the afore mentioned function. This is NOT K&R C behavior.
But if you leave out the function name, printf() will send each character, one at a time (see the pattern here?) to the active serial stream. You can have more than one serial stream in which case you simply switch streams just before calling printf() to make the appropriate routing or use fprintf and name the stream within the function call.
This is covered in the compiler's manual, page 146 for the copy I have on file (March 2006) but if you just look in the table of contents for printf() you can read all this for yourself. Furthermore, you can compile a short test program and follow along in the LST file.
If you dont' understand how to format strings with printf(), fprintf(), sprintf() or vsprintf(), then go read K&R's book. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
|
|
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
|