I need to take a peek at what's inside a declared unsigned char pointer, I reduced my problem to this short example
#include<iostream>
int main (int argc, char *argv[])
{
unsigned char * buffer = new unsigned char;
*buffer = 8;
std::cout << "buffer = " << (unsigned char) (*buffer) << std::endl;
}
I am expecting this output : buffer = 8
But I get buffer =
Blank, which drives me nuts, not even any value !!!
How I am actually dealing with it :
#include<iostream>
typedef unsigned char uint8_t;
int main (int argc, char *argv[])
{
uint8_t * buffer = new uint8_t ;
*buffer = 8;
std::cout << "buffer = " << (int) (*buffer) << std::endl;
}
I am using this example in ns3 , buffer constructs a one byte payload packet, and I need it to be a pointer. That's why I actually tagged my question as "C" along with "C++", because the core of the issue is also concerned in C. But I found myself down voted for that ! I know "cout" and "new" are c++ literals, but it's irrelevant to the issue !!
Not having a coding problem with all that, my problem is just what's unsigned char then if it reads as a regular char with cout !!!!!
I stated I am expecting it to be buffer = 8
because unsigned char are one byte integers.
Thank you guys because you made me notice cout is dealing with it as if it is a regular char, despite it was expected for me otherwise.