/** * Writing bits into a variable * Requires that one command line arg. That * arg mist be a binary string and it should be * at least 8 bits * * @author gtowell * Created: April 2021 * **/ #include #include int main(int argc, char const *argv[]) { unsigned char aa = 0; for (int i = 0; i < 8; i++) { if (argv[1][i] == '\0') break; aa <<= 1; if (argv[1][i] == '1') aa |= 1; } printf("%d\n", aa); return 0; }