You cannot purposefully apply an unsigned long to void * . The first is a numerical value; the last is the address of the unspecified data. Most systems implement pointers as integers with a special type (which includes any system that you are likely to encounter in everyday work), but the actual conversion between types is considered harmful.
If what you want to do is write the unsigned int value to the file descriptor, you must take the address of the value using the & operator:
unsigned int *addressOfMyIntegerValue = &myIntegerValue; pwrite(fd, addressOfMyIntegerValue, sizeof(unsigned int), ...);
You can scroll your vector or array and write them one by one with this. Alternatively, they can be written more quickly using the std::vector function of continuous memory:
std::vector<unsigned int> myVector = ...; unsigned int *allMyIntegers = &myVector[0]; pwrite(fd, allMyIntegers, sizeof(unsigned int) * myVector.size(), ...);
source share