Lab Description:
The Lab six was about packing data and unpacking data. There is a lot of way to do this but I Used loops, string, and char. You can use bit wise and shift to do this. I put the input as character which is just a regular string, and to do the output of ASCII to hex I did a for loop. I than started working on the conversion from Hex to ASCII and to do that I input the users variable in hex and than I compared the character and equal it to my hex value. I thank displayed the char variable which is equal to hex.
#include
#include
using namespace std;
int main()
{
int x,y;
string character;
int z = 0;
char h[4];
int a;
cout << "Choose (1) to pack or (2) to unpack" <> x;
if (x == 1)
{
cout << "ENTER a Character" <> character;
for (z; z < character.length(); z++)
{
cout << hex << "The packed data are:" << (int)character[z] << endl;
}
}
else if (x == 2)
{
cout << "Enter a hex value" <>hex>> a;
char thexa =a;
cout << "The ASCII character is:" << thexa << endl;
}
