Returning an array of tm* structs from a function
Posted
by paultop6
on Stack Overflow
See other posts from Stack Overflow
or by paultop6
Published on 2010-04-01T12:19:47Z
Indexed on
2010/04/01
12:23 UTC
Read the original article
Hit count: 367
c++
Hi Guys,
Im trying to create an array of tm* structs, and then return them at the end of the function. This is what i have at the moment:
struct tm* BusinessLogicLayer::GetNoResponceTime()
{
struct tm* time_v[3];
struct tm* time_save;
int s = 3;
time_save = LastSavedTime();
time_v[0] = time_save;
sleep(5);
time_save = LastSavedTime();
time_v[1] = time_save;
sleep(5);
time_save = LastSavedTime();
time_v[2] = time_save;
return time_v;
}
I understand that given the code i have now it will not be possible to return the array, because it will be destroyed when the function ends. Can anyone help me with regards to how i would go about being able to access the array from the returned value after the function has ended?
Regards
Paul
© Stack Overflow or respective owner