//buf is a character array //pBuffer is a pointer to a character array //sprintf does not output the hex of each character, rather the actual character while (*pBuffer) { sprintf(buf, "%x ", *(pBuffer++)); }