I have been looking at other posts and trying to get this working for a bit, but can't seem to manage it.
Basically I want to pass a "char myArray[10]" though into a function, have the function assign the values and then hand it back. It generally looks like this at the moment:
int MyClass::GetArray(char array[10])
{
char p[10];
... // a value is assigned to p
memcpy(&array, &p, sizeof(p)); // Here array ends up being 0x3232323232323232 <Error reading characters of string.>
return 0;
}
Called with:
char array[10];
myclass.GetArray(array);
So, I assume I need to pass the array through as a reference to the array[10] created before calling the function. But for that I am unsure how to create a pointer to a fixed array without making it either a general char* pointer or a pointer to an array of chars.
Secondly is the memcpy error (in the code comments above). I'm not sure if that is related or not though.
std::arrayin place of built-in arrays. It has asizefunction (you don't know the size of the parameter in your example) and it supports assignment.arrayinstead of&array. It'll decay to a pointer to the first element. Same forp. Why are you copying the memory anyway? (Actually, it could only (easily) make sense if you were passing a reference to the array, but that's what you're asking about, so nevermind~)