SoFunction
Updated on 2025-03-11

c++ Solution to convert a binary string into an integer


<SPAN style="FONT-SIZE: 18px"> char* p = "1010110001100";
 int n = 0;
 for(int i=0;i<strlen(p); i++)
 {
  n = n * 2 + (p[i] - '0');
 }
 printf("%d\n", n);</SPAN>