How to pass char arrays to methods

I have been unable to pass character arrays as parameters to a method. Does anyone know how to do this?

You pass the pointer to the array not the array itself.

This code passes a char array to the Serial.println function:

char foo[] = "Hello, world!"
Serial.println(foo);

What are you trying to do, and what is the problem?

-br

armordkar: I have been unable to pass character arrays as parameters to a method.

You would normally do this by declaring a formal argument of type pointer-to-element; if the size of the array isn't already known you will need to pass that in separately, since the size of the array is only known to the compiler when your refer to the array variable directly. The type of the array is also pointer-to-element, so you can use the array variable as the argument value.

int myArray[5];

void bar(int *foo);

bar(myArray);