Horje
convert int to binary string c++ Code Example
convert int to binary string c++
std::string str = std::bitset<8>(123).to_string();
convert long int to binary string c++
auto int_bits_size = 32; // maximum number of bits for the integer
auto some_integer = 123456789;
std::string str = std::bitset<int_bits_size>(some_integer).to_string();
number to binary string c++
  ==== Convert number to binary string C++ ======
 int n = 100;
 string s1=""
//Method 1:
 string s1 = bitset<8>(n).to_string(); // 01100100
//Method 2
 while(n) {
 	s1 += (n%2) + '0';
    n /= 2;
 }
 reverse(s1.begin(),s1.end()); // 1100100




Cpp

Related
slice std::array cpp Code Example slice std::array cpp Code Example
div content editable Code Example div content editable Code Example
c++ nested switch statements Code Example c++ nested switch statements Code Example
getting a random letter in c++ Code Example getting a random letter in c++ Code Example
call by value in c++ Code Example call by value in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8