I'm trying to make a program that takes in an integer value and then prints out the value of each of the four bytes in hex. So for 255 it should print out FF 00 00 00. This is what my code is looking like so far.
#include "pch.h"
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int num;
cout << "Enter an integer" << endl;
cin >> num;
int* p = #
unsigned char* q = (unsigned char*)p;
for (int i = 0; i < 4; i++) {
cout<< hex <<*(int*)(q+i) << " ";
}
}
When I enter 255 it prints ff cc000000 cccc0000 cccccc00
What are the c's?