Here is a structure:
struct elem {
int a[100];
int val;
};
elem foo() {
elem Result;
Result.a[0] = 5;
return Result;
}
int main () {
elem aux = foo();
//is Result passed back to aux, so that we can use its array?
cout<<aux.a[0]<<"\n"; // 5
}
I know that functions ca return simple structures. Can they also return structures that contain arrays? What happens within the memory?
And also: when we declare elem Result; in the function, is the array initialised with 0, or it just takes random values?