I already have XXX struct and getXXX() function.
Now i need function to access yyy field of XXX struct.
typedef struct _XXX_ {
//--other data
char yyy[MAX_YYY_LEN];
} XXX;
XXX *getXXX(void);
const char* myFoo(void){
XXX *ptrToXXX;
ptrToXXX = getXXX();
return ptrToXXX->yyy;
}
I have two questions:
Will data returned by myFoo() be accessible after function termination, or it may point to nowhere, cause out of scope?
Do i need to destruct ptrToXXX ? I mean, if i call myFoo() 1000000 times - will it allocate a lot of memory for XXX * pointers?
Thank you.