Last active
November 25, 2016 08:33
-
-
Save matteyeux/e49e362857f9bad898e2358baa981eb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*gcc get_netmask_suffix.c -o get_netmask_suffix*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netdb.h> | |
int main(int argc, char *argv[]){ | |
int n, i=0; | |
// Il faut au moins un argument | |
if (argc != 2) | |
{ | |
printf("usage : %s <netmask>\n", argv[0]); | |
return 0; | |
} | |
inet_pton(AF_INET, argv[1], &n); | |
while(n > 0){ | |
n = n >> 1; | |
i++; | |
} | |
printf("Netmask suffix : %d\n", i); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment