Go Down

Topic: Passing String objects as parameters to a function (Read 1 time) previous topic - next topic

glenz

Hello All,
         I am a newbie to C. All I know about it has come from working with Arduino. This is my current hang-up, on which I have worked for hours.
I want to be able to pass alphanumeric strings in the form of String objects to a function which does some formatting on it and passes it back in the formatted state. I want to be able to call this function from various points in the sketch with Stings of various names.  I'm sure this can be done but I can't figure out the syntax.  Basically it would look like this....

Code: [Select]

String MyString = "some alphanumeric text";

void loop(){
    format_string(MyString);
}

void format_string (String anyString){
   //do some formatting
}


I'd appreciate any help.

Coding Badly

#1
Mar 31, 2011, 08:56 pm Last Edit: Mar 31, 2011, 08:58 pm by Coding Badly Reason: 1
Quote
void format_string (String & anyString){
  //do some formatting
}

glenz

Thanks a bunch. That works.
Your reply has got to be the all-time briefest successful reply to a query... one character long! No one can beat that. It is an atom of language.
Gives new meaning to,  "Let me give you a "bit" of advice. :D


Go Up