Hello,
Yes, I understand in C++ you would use new.
However, we are doing some low level stuff as the library we are using is written in C. And new was giving us some unexpected results.
Now I understand the sizeof situation. That point is clear.
However, I am still wondering is this is still ok.
Code:
ptrVP[0] = 10;
ptrVP[1] = 20;
ptrVP[2] = 30;
ptrVP[3] = 40;
std::cout << "ptrVP[0]: " << ptrVP[0] << std::endl;
std::cout << "ptrVP[1]: " << ptrVP[1] << std::endl;
std::cout << "ptrVP[2]: " << ptrVP[2] << std::endl;
Using pointer arithmetic. Would this be the same as above.
Code:
*ptrVP = 10;
std::cout << "ptr 10: " << *ptrVP << std::endl;
ptrVP++;
*ptrVP = 20;
std::cout << "ptr 20: " << *ptrVP << std::endl;
ptrVP++;
*ptrVP = 30;
std::cout << "ptr 30: " << *ptrVP << std::endl;
Thanks,