i need to return a struct pointer dynamically allocated inside a function call void function() which is done using 'out parameters' in following code
1 2 3 4 5 6 7 8 9 10
struct my_struct
{
int x;
}
void my_function( my_struct** result )
{
my_struct* x = new my_struct{ 10 };
//...
*result = x;
}
now i have a doubt, so if i want to print the return value from struct pointer, should i need to print it in the void function() or in the caller the function
@Peter87
i have another paradigm where i need to print a pointer of type struct which gets the value dynamically in each iteration and also print a defrenced struct member on each iteration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
struct my_struct
{
int x;
int y;
}
void function(){
my_struct* a=tls.get() // some values will be assigned dynamically to this pointer from other part of function.
my_struct* data = new thread_data;
data->x=1 //which will get updated according the iterations and conditions
data->y=2 //which will get updated according the iterations and conditions
}
now i need to print the values of a,x,y in the caller function. How to print those values. some what like
printf("a=%lx x=%i y=%i\n", a,x,y);
can you please give me some ideas or how to proceed? thanks alot