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

how to use printf(); function

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



Joined: 06 Mar 2007
Posts: 92
Location: Pune,India

View user's profile Send private message AIM Address Yahoo Messenger

how to use printf(); function
PostPosted: Wed May 16, 2007 4:00 am     Reply with quote

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
Code:
char c

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

View user's profile Send private message Send e-mail

PostPosted: Wed May 16, 2007 7:31 am     Reply with quote

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!
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