int binaryToInt(char* s) { int result = 0; for(int i = 0; s[i] != '\0'; i++) { result = 2*result + (s[i] - '0'); } return result; }