A C Program To determine IP class from an IP address ~ Ofuran

A C Program To determine IP class from an IP address

A C Program To determine IP class from an IP address. Copy and compile this on your computer. 



#include<bits/stdc++.h>

int main()

{

    char ip[50];

    gets(ip);

    int i;

    for(i=0; i<=strlen(ip); i++)

    {

        if(ip[i] == '.')

            ip[i] = '\0';

    }

    int ip_part = atoi(ip);

    if(ip_part<=127 && ip_part>=0)

        printf("Class A");

    else if(ip_part<=191 && ip_part>=128)

        printf("Class B");

    else if(ip_part<=223 && ip_part>=192)

        printf("Class C");

    else if(ip_part<=239 && ip_part>=224)

        printf("Class D");

    return 0;

}


'