I've tried the following:
char[10] testfunc() { char[10] str; return str; }
Best as an out parameter:
void testfunc(char* outStr){ char str[10]; for(int i=0; i < 10; ++i){ outStr[i] = str[i]; } }
Called with
int main(){ char myStr[10]; testfunc(myStr); // myStr is now filled }
2.1m questions
2.1m answers
60 comments
57.0k users