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 a string as param in a function

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








How to use a string as param in a function
PostPosted: Wed Apr 09, 2008 1:59 am     Reply with quote

Problem to use a function to transfer a string?

Smal ex. to show the problem.

Code:
void disp_print(st???){
 printf(mydev,"%s",st);
}


void main{
 //test 1 working direct printing
 printf(mydev,"testing"); //working and string is placed in ROM.
 
 //test 2
 disp_print("testing");  //how to do this?

}
Matro
Guest







PostPosted: Wed Apr 09, 2008 2:07 am     Reply with quote

Parameter type is "char*".

Matro
Matro
Guest







PostPosted: Wed Apr 09, 2008 2:10 am     Reply with quote

Notice that for this example to work properly, you have to add :
Code:

#device PASS_STRINGS = IN_RAM

in your code.

Matro
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Wed Apr 09, 2008 6:27 am     Reply with quote

Or alternatively:
Code:
void disp_print(char c){
  fputc(c, mydev);
}

void main{
  disp_print("testing");
}
The compiler will automatically create the loop to call disp_print once for each character in the string.
_________________
Andrew
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