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

Sprintf

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



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

Sprintf
PostPosted: Wed May 19, 2010 11:51 pm     Reply with quote

Quick question..

My C skills is somewhat incomplete on print functions.


This code works .
Code:

    sprintf(msg,"hello");
    print(3,0,msg);


Code:

void print(int x, int y,char* msg)
{
   
    setCursorAddress(((x*37)+y)-37);
    printf (Glcd_PutC, msg) ;
}



I would like to eliminate the first line sprintf(msg."hello") and replace it with print(3,0,"hello") or print(4,1, data)

Can some one point me to the right direction here.
compiler 4.105
Thanks
_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 20, 2010 12:32 am     Reply with quote

Quote:

I would like to eliminate the first line sprintf(msg."hello") and replace it
with print(3,0,"hello").

You can tell the compiler to pass strings to functions in an internal
temporary RAM buffer by adding the statement shown in bold below:
Quote:

#include <18F452.h>
#device PASS_STRINGS=IN_RAM
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

Then you don't need the sprintf().
dezso



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

PostPosted: Thu May 20, 2010 7:08 am     Reply with quote

Awesome

It also save me 20byte Smile

Thanks
_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
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