Here is my problem : I have a structure :
typedef struct Data_Package{
int type;
size_t size;
void* data;
}Data_Package;
and I have a function : (Edit : Armen Tsirunyan remarks) (it is a .C function)
void myFunc(Data_Package* ioData) {
ioData->data = malloc(sizeof(double));
(ioData->data)= (double*)62.5
} //that doesn't work
and the main.cpp where I would like to use my function :
Data_Package* ioData=0;
/* some random operation that change the data,type,... */
myFunc(ioData);
stc::cout << *static_cast<double*>(ioData->data) << std::endl //I want to display te value data (and not the address)
So I would like to know how to change the value data in my function and then display it in the main.cpp (I need to use pointer and data is void* because it could be double or bool or int or ...)
Thanks a lot.
Drlk.
boost:variant.(double*)62.5). @ArmenTsirunyan showed you how to do this -*(ioData->data) = 65.5;.Try it.