Use std::bitset:And that's #include <string> NOT #include <string.h>...Code:#include <iostream> #include <fstream> #include <bitset> int main() { std::ifstream InFile("binary.txt"); std::bitset<8> Byte; if(!InFile) { std::cerr << "Unable to open the file." << std::endl; return 1; } while(InFile >> Byte) { std::cout << Byte << ": " << static_cast<char>(Byte.to_ulong()) << std::endl; } system("pause"); return 0; }
EDIT: Too late..![]()




Reply With Quote