Ok so far I got this, it takes a string of characters and prints out their binary representations. I am semi new to C++ and I cant for the life of me figure out how to get the hexidecimal and octal representations of the input.
Here is the code so far:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void displayBinary(unsigned);
void main()
{
string input;
cout << "Enter a string: In other words start typing. Use @# for the escape sequence." << endl;
while(input != "@#")
{
getline(cin, input);
for(int i =0; i < input.length(); i++)
{
cout << input.at(i) << " = ";
displayBinary((unsigned)input.at(i));
}
cout << endl;
}
}
void displayBinary(unsigned u)
{
register int b;
for(b = 128; b > 0; b = b/2)
{
(u & b)?(cout << '1'):(cout << '0');
}
cout << " ";
}