mirror of
https://github.com/riba2534/TCP-IP-NetworkNote.git
synced 2026-02-03 01:53:19 +08:00
23 lines
508 B
C
23 lines
508 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <arpa/inet.h>
|
|
void error_handling(char *message);
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
char *addr = "127.232.124.79";
|
|
struct sockaddr_in addr_inet;
|
|
|
|
if (!inet_aton(addr, &addr_inet.sin_addr))
|
|
error_handling("Conversion error");
|
|
else
|
|
printf("Network ordered integer addr: %#x \n", addr_inet.sin_addr.s_addr);
|
|
return 0;
|
|
}
|
|
|
|
void error_handling(char *message)
|
|
{
|
|
fputs(message, stderr);
|
|
fputc('\n', stderr);
|
|
exit(1);
|
|
} |