Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15514

How do you pass a string into a function?

$
0
0

I need to pass a string variable into a function that changes it and sets a flag high so that it enters an if statement the next time through the loop that updates an HMI.

The applicable portion of the code are as follows:

char machineStatus[] = "";

// using the function
writeString(machineStatus, "idle");


// the non working function
void writeString(char *stringName, char *newString){

  stringName = newString;
  updateStrings = 1;

}

This complies and goes onto the arduino with no issues however the machineStatus doesn't get updated, only a new string called stringName is made and updated as "idle" in this case. I don't want a new new string, I just want the machineStatus string to change to "idle" in this case.

Any help on this would be greatly appreciated!

4 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 15514

Trending Articles