Not sure what you are trying to achieve, but it depends on where did you get the packet.
1) Printing the packet from your own application
2) Printing the packet of other application:
a) Sniffing using external resources -> Raw Sockets, sniffing drivers etc.
b) Sniffing from inside of the process -> ws2_32.recv ws2_32.send
In all cases I recommend you to print the packet as hexdecimal numbers. As-long the data isn't text only.
for(int i = 0; i < nSizeOfPacket; i++)
{
printf_s("%02X ", byPacketBuffer[i]);
}
Where byPacketBuffer is unsigned char * pointer to the packet data.
OR
STL
for(int i = 0; i < nSizeOfPacket; i++)
{
std::cout << std::hex << (int)byPacketBuffer[i] << " ";
}
You can use iomanip header to set width and fill of the output. ( a b ba c ca -> 0A 0B BA 0C CA)