now its plain as day xD ;)
p dereferences the pointer and fetches the byte at the current position that the char pointer points to.
Similarly, p[n] fetches the nth byte from the position of the pointer p.
Since it is a char* pointer, when dereferencing the pointer, we get a char.
Naturally, since char is a character, std::cout will print out the character it represents.
To avoid this, we cast it to int to make sure it prints out the actual byte.
Coupled with std::hex prints out the hex presentation of the number.
This is only necessary when printing.