Suppose I want to write a C++ function foo() that updates the value of an input string. How do I do it? The code should probably look something like I have below but I don't know how to properly pass the string such that it is updated by the function.
void foo(String x) // Not sure if I should put an & or * before x
{
x += " Goodbye";
}
void main()
{
String x = "Hello World";
cout << "x = " << x << endl;
foo(x); // Not sure if I should pass a pointer to x,
// a reference to x or what?
cout << "After foo (), x = " << x << endl;
}
(FYI, I'm writing this for an Arduino processor)