Hello (sorry if i break any rules on post format first time on daniweb)Have a project to make a binary to hex,Dec,octal. Now i found this code here
http://www.daniweb.com/forums/post598839.html#post598839 and made a few changes to it but i am not familiar with a few of the parts and some help would be appreciated (didn't know how to highlight so put // on the line and question on what it does)
#include <iostream>
#include <iomanip> // what is this library used for
#include <string>
#include <bitset>
using namespace std;
int main()
{
std::cout << "Enter a binary number: ";
std::string bin;
if (getline(std::cin, bin)) {
bitset<32> bits(bin);
cout <<"Octal ";
cout << std::oct << bits.to_ulong() << '\n'; //what does the bits.to_ulong() part do or what is it tied to .
cout <<"Hex ";
cout << std::hex << bits.to_ulong() << '\n';
cout <<"dec ";
cout << std::dec << bits.to_ulong() << '\n';
}
return 0;
}