I want to rewrite code that uses many arrays unsigned char, use objects instead std::vector<unsigned char>. The problem lies in the fact that they are now used to store data to be written to the serial port or socket write buffer and to perform library functions require either void*or unsigned char*. An example of such a function is
WriteToSocketBuffer(unsigned char* pBuffer, int iSize);
so currently i have a form code
unsigned char* pArray = new unsigned char[iSize];
WriteToSocketBuffer(pArray,iSize);
delete [] pArray;
My question is this: if I change my class to std::vector<unsigned char>instead of a raw array, I can just call my library function using
std::vector<unsigned char> myVector;
WriteToSocketBuffer(&myVector[0],myVector.size());
, . ?