Say i have a char* method that returns a char array. How mould i set another char array equal to that return value? For example, here's the char* method:
char* work(int num){
char buf[32];
sprintf(buf, "%d", num);
return buf;
}
what do I need to put in the main method to use the returned value? I've tried
int main() {
char rValue[32] = work(5);
}
but i get "error: array initializer must be an initializer list or string literal"
and
int main() {
char rValue[32];
rValue = work(5);
}
gives me "error: array type 'char [32]' is not assignable".
I know that the solution is probably extremely simple, but i'm lost. How can i access the returned value?