C program to convert IPv4 address from String formatted in dat notation like "10.0.0.1" to a 32 bit integer in Linux
#include<stdio.h>
#include <arpa/inet.h>
main()
{
uint32_t ip;
struct in_addr ip_addr;
ip = inet_addr("10.0.0.1");
printf("IP Integer: %d\n", ip);
ip_addr.s_addr = ip;
printf("The IP address is: %s\n", inet_ntoa(ip_addr));
}
#include<stdio.h>
#include <arpa/inet.h>
main()
{
uint32_t ip;
struct in_addr ip_addr;
ip = inet_addr("10.0.0.1");
printf("IP Integer: %d\n", ip);
ip_addr.s_addr = ip;
printf("The IP address is: %s\n", inet_ntoa(ip_addr));
}
No comments:
Post a Comment