0

Is putting in binary as a value possible? I want something like char test = 00101011 and it will become 43. I know this is possible by making a function that converts binary to decimal (which can be inputted) but thats not direct and Im pretty sure it takes time.

Bfyuvf
  • 139
  • 9

1 Answers1

0

You need to put the prefix 0b.

#include <iostream>

int main()
{
    char c = 0b00101011;
    std::cout << static_cast<int>(c) << std::endl;
}
kiner_shah
  • 3,939
  • 7
  • 23
  • 37