I am doing some programming, I wanna convert the netmask to network prefix length.
For example 255.255.255.0 ----> 24.
Finally I write some code to do so.
const char *network = "255.255.255.0";
int n = inet_addr(netowrk);
int i = 0;
while (n > 0) {
n = n << 1;
i++;
}
i will be the network count