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
}
More Related Contents:
- Return array in a function
- C++ return array from function [duplicate]
- Function returning array but main showing garbage [duplicate]
- Possibilities to quit a function
- Why doesn’t C++ support functions returning arrays?
- Why can’t we pass arrays to function by value?
- Difference between [square brackets] and *asterisk
- C++ correct way to return pointer to array from function
- Function in C++ returns by value or by reference?
- Pointer to array of unspecified size “(*p)[]” illegal in C++ but legal in C
- How to return array from C++ function to Python using ctypes
- What happens when a function that returns an object ends without a return statement
- array of pointers as function parameter
- Invalid operands to binary expression while implementing vector [closed]
- For loop with an array
- Difficulties on atributting a array to another [closed]
- Function does not change passed pointer C++
- How to return an array from a function?
- return statement vs exit() in main()
- Difference between a virtual function and a pure virtual function [duplicate]
- How do you initialise a dynamic array in C++?
- Is it possible to std::move objects out of functions? (C++11)
- What is useful about a reference-to-array parameter?
- Passing array of structures to function c++
- What is the use of 0-length array (or std::array)?
- can’t modify char* – Memory access violation
- Does std::cout have a return value?
- How to create a template function within a class? (C++)
- Returning a void?
- Can I get polymorphic behavior without using virtual functions?