Bit masking

I am having trouble creating a bit mask, the whole concept is not really sticking with me. This program stores multiple numbers into a single variable and then should be able to extract each one as requested.

#include <iostream>
#include <ctime>
using namespace std;

int mask(unsigned int packit);
void main(){

srand(time(NULL));
unsigned int packit = 0;
unsigned int temp;
int request;
int mask = 1;

for (int i = 8; i >= 1; i--){

packit = packit << 4;
temp = rand() % 15;
cout << i << " temp is: " << temp << endl;
packit = packit ^ temp;
cout << "packit is: " << packit << endl;

}

cout << "Which number do you want? (Max: 8)" << endl;
cin >> request;

request = request - 1;
request = request * 4;

packit = packit >> request;

cout << packit << endl;



system("pause");
}

int mask(unsigned int packit){

}

This is pretty much as far as I have gotten. How do I create a mask that can cover up the unwanted bits?
Topic archived. No new replies allowed.