I am trying to use this example:
std::size_t s2 = boost::asio::buffer_size(buffer);
const void* p2 = boost::asio::buffer_cast<const void*>(buffer);
And I am getting a vaild size s2 and some seemingly valid address p2.
Now, how could I create a cout or printf loop or phrase a debug-statement, to see the content of p2?
I bet this is quite basic, but currently I can’t see what I am missing.
Tried this:
std::cout << "TEST: " << boost::asio::buffer_cast<const void*>(buffer) << std::endl;
but it only prints out the address, not the content
and this:
for(int i =0; i!=s2; i++){
std::cout << "TEST: " << p2[i];
}
std::cout << std::endl;
but I am ending up with compile errors, like C0253 – unknown size.
So, how can I print out the content of p2?
You can print the bytes pointed to by buffer as:
Of course, you have to interpret the output.
You can print the hexadecimal values instead which is easier to interpret:
I think you have to
#include<iomanip>for this.