c++ - Take input in array of bool -
i want take input in array of bool
bool bmp[32];
and program interaction.
enter binary number : 10101
i want store user input of '10101' in array of bool like.
bmp[32]={1,0,1,0,1};
please help!!
nothing fancy, read data , store array this:
#include <string> #include <cstdio> int main() { std::string str; std::cout << "enter binary number : "; std::cin >> str; bool b[32]; std::size_t size = 0; (auto c : str) { b[size++] = c == '1'; } // set now. return 0; }
Comments
Post a Comment