You can't return an array, you can return a pointer to an array. But be careful because local arrays (which are not created dynamically with new) gets destructed as soon as the function returns. So this won't work:
1 2 3 4
char *bad_array_return() {
char a[] = { 1, 2, 3, 4 };
return a; //BAD, the returned pointer will be invalid
}
Using dynamic arrays:
1 2 3 4
char *dynamic_array_return() {
char *a = newchar[4];
return a; //the returned pointer will be fine, but make sure you delete it after use.
}
The best is to use std::vector (or any other STL container)