Doesn't matter which one really. I want to try my hand at encoding something, so i chose a word, and tried this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
int main()
{
string ss;
cout << "Enter something\n";
getline(cin,ss);
cout << ss << endl;
cout << hex << ss << endl;
cout << dec << ss << endl;
cout << oct << ss << endl;
cin.get();
cin.get();
return 0;
}
however the output is the exact same as the input. I've done some rudimentary searches, but have yet to find anything.
note* currently compiling on dev cpp, because i didn't feel like making a project and everything for msvc2010. I can switch if this idea won't work on dev.
This will display the first character in the string in the way you wish to display it. I trust you will be able to modify appropriately to display every char in a string.
for the binary example at least. Hex/dec/oct were much easier as after feeding the letter into an int to get the code, you just set a stream with iomanip to the particular setting you want.
note* i know that binary holds the actual binary code backwards, i figured out how to take care of that as well.