I have a pointer returned from malloc. Which points to first byte of allocated size. For EX:
void* p=malloc(34);
How to print the binary values contained in those 34 bytes. ?
I have a pointer returned from malloc. Which points to first byte of allocated size. For EX:
void* p=malloc(34);
How to print the binary values contained in those 34 bytes. ?
You probably want this :
int i ;
void* p=malloc(34);
for (i = 0; i < 34; i++)
{
unsigned char c = ((char*)p)[i] ;
printf ("%02x ", c) ;
}
It doesn't print in binary (010011011) but in hexadecimal, but that's probably what you want.
But as stated in the comments you will get garbage values.