Functions returning char arrays
now i have a most confusing problem. I have a function that returns a string (actually i have a number of them), and i want to store this string in another char array. My first thought was to try saying
array = function ();
but of course I found that didn't work just like
string1 = string2
won't work. Then I thought of using strcpy :
strcpy ( array , function() );
I'm not sure why, but I couldn't make that work either. It occured to me I could try a manual method of copying with a loop, but I couldn't see that working unless I stored function() into a variable first, which is the whole problem! So i thought screw it, no more passing arrays, i'll pass pointers. This worked for some of my functions, but for ones that initialise the array that needs to be returned within them, returning the pointer.. well, you can't return a pointer pointing to a local variable so my compiler tells me.
So, in conclusion, i'm very stuck. Please help me if you know how to get around this sort of problem!