Created
January 4, 2019 14:55
-
-
Save nukopy/bdfe25c0397a3438585ff36e1fda351b to your computer and use it in GitHub Desktop.
decimal to binary string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <bitset> // static_cast<std::bitset<8>> | |
#include <sstream> // std::stringstream | |
using namespace std; | |
int main() { | |
int num = 55; | |
stringstream ss; | |
ss << std::bitset<8>(num); | |
string s = ss.str(); | |
cout << s << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment