I have a function that needs to return an array, as this is not possible it instead returns the pointer to that array. I then need to print this array in the main function. How do I do this?
Here is an example of what I mean:
char* myFunction (void)
{
char myArray[5] = {'one','two','three','four','five'};
return myArray;
}
int main(void)
{
printf("%s",myFunction);
return 0;
}
But this just prints the pointer: uF$. Or if I print the function as an integer instead, it prints: 791013. So how do I actually print the 5 elements in the array?
Thanks!