-
-
Save hausdorff/8141382 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
#include <arpa/inet.h> | |
#include <netinet/in.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
void convert_both_ways(); | |
int main(int argc, char **argv) | |
{ | |
/* convert integer address to dotted decimal, | |
then convert it back*/ | |
convert_both_ways(); | |
exit(0); | |
} | |
void convert_both_ways() | |
{ | |
char *dotted; | |
struct in_addr address; | |
address.s_addr = 0x8002c2f2; | |
dotted = inet_ntoa(address); | |
printf("Converting address 0x%x to dotted-decimal: %s\n" | |
, address.s_addr, dotted); | |
printf("Converting dotted-decimal %s to address: 0x%x\n" | |
, dotted, address.s_addr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment