The task is to create an array with different types of variables, the number of elements is not known in advance. I'm trying to help memcpy create an array with different data types, like this:
char * packet; float a=1.56; int b=5; memcpy(packet,&a,4); memcpy(packet,&b,4); But the segmentation fault error occurs. Tell me please, is it actually implemented in such a way, or am I trying to do something wrong?
boost::any. If there is any hierarchy of stored types, then (smart) pointers can be used. All this as a type forstd::vector, for example. True, I suspect that it will be difficult for you at the moment. - αλεχολυτ