i m trying to make a program to convert a number into it's binary.
Code:
#include<iostream>
#include<algorithm>
#include<bitset>
using namespace std;
int main()
{
int a;
string k;
bitset<CHAR_BIT> n;
cin>>a;
n=bitset<CHAR_BIT>(a);
cout<<n<<" ";
return 0;
}
The program gives wrong answer for 585 as it contains more than 6 binary digits. How can i such greater numbers?