|
|
View previous topic :: View next topic |
Author |
Message |
dezso
Joined: 04 Mar 2010 Posts: 102
|
Sprintf |
Posted: Wed May 19, 2010 11:51 pm |
|
|
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 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 20, 2010 12:32 am |
|
|
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
|
|
Posted: Thu May 20, 2010 7:08 am |
|
|
Awesome
It also save me 20byte
Thanks _________________ I'm could be wrong many time's, at least I know what I'm doing |
|
|
|
|
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
|