Hello,
I have a function that takes two array parameters and returns a new character array based on the concatenation of the first parameter with the second parameter at the end.
This function works (given below):
//this function takes two character arrays, concats them and returns a new returnable char array
char * conCatNew(char f[], char s[])
{
//create the temporary array
char temp[250];
//copy the first argument then concat the second argument to the temp array
strcpy(temp, f);
strcat(temp, s);
//return the temp array to the invocation
return temp;
} //end conCatNew function
However, my compiler VS .net is giving me a warning:
dig2.cpp(178) : warning C4172: returning address of local variable or temporary
I would like to make the temp arrary a permanent return to be used from the place of invocation without this warning.
Do I need to do a reference return? I do not know how to do this with an array.



LinkBack URL
About LinkBacks


