A function written in C e.g.
extern "C" void cityManipulator( void * data, int size);
takes an array similar to this,
Shanghai, China, 17
Delhi, India, 16
Cairo, Egypt, 7
It then capitalizes the city names and multiplies the population number by a one million.
The function works with the value that I pass not the copy.
The function requires to know the dimensions of the array: how many rows and columns and the size in bytes of each element ( i.e. each city name ) in a given column
I am not interested in how the C function works but I want to use it as is from C++.
The array has to be dynamic i.e. the columns and rows are not static.
How should my data structure that I need to pass to this function look like?
This is my attempt. Use a nested vector of boost::variant
typedef boost::variant<std::string, int> Var;
typedef std::vector<Var> OneRow;
std::vector<OneRow> theArray;
But I can't figure out how to pass theArray
to cityManipulator( void *d ).
&theArray[0]
does not work.