Pejman Moghadam / C-programming

C - inet_ntop

Public domain


inet_ntop : convert IPv4 and IPv6 addresses from binary to text form

#include <stdio.h>
#include <string.h>
#include <arpa/inet.h> 

int main()
{
    char dst[INET_ADDRSTRLEN];
    struct in_addr src;

    src.s_addr = 0x142AAA53;
    inet_ntop(AF_INET, &src, dst, INET_ADDRSTRLEN);
    printf("Network = %X\n", src.s_addr);
    printf("Presentation = %s\n", dst);

    return 0;
}

BY: Pejman Moghadam
TAG: c, inet-ntop
DATE: 2014-01-21 02:04:33


Pejman Moghadam / C-programming [ TXT ]