I have just started my back-to-the-roots project; learning C. I'll be honest, abstraction is nice when you need to plow out a desktop/server application, but with C, things get personal. Which is nice, for a change!
Now to the point; I'm reading into using arrays with functions (Programming in C, Stephen G. Kochan.) I have learnt that when passing an function as a parameter the compiler will always see the reference as a pointer, like so:
void foo (char *array);
Take this, for example:
void foo (char *a)
{
a[0] = 'R'; // side effect
}
int main (void)
{
char a[] = "The quick brown fox jumps over the lazy dog!";
foo (a);
}
I haven't come by information on functions returning arrays or pointer to an array. The function rather changes the array in its parameter, thus causing side effects (as seen above).
Is it possible for a function to return a pointer to an array? Or is the above method just preferred?
Thanks in advance for those that can offer an explanation.