I want to read a text file that contains 0 and 1 as binary, consider this example:
i want to read this stream of 0 and 1 as binary or read then convert it. If we consider first line "001001100101", i want to it convert to 613 decimal and then with bit field or something like that, i check every bit of every number that was read. Only way that can do is read line by line and then parse to string after that check every splitted string with "1" or "0" and find real value. I think there is a simple way for this problem.
Thanks a lot.
If there are only 0 and 1 in your file,
you can use stl std::stoi(const string& str, [size_t* idx], [int base])
string bin_string = "001001100101"; int number = stoi(bin_string, nullptr, 2);