This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
inet_aton 0x0 in integer in structure
- From: alleswirdbesser at posteo dot de
- To: libc-help at sourceware dot org
- Date: Thu, 11 May 2017 20:38:51 +0200
- Subject: inet_aton 0x0 in integer in structure
- Authentication-results: sourceware.org; auth=none
I used inet_aton, received 1, expected an integer in the structure. Why
is it 0x0?
(gdb) break 12
Breakpoint 1 at 0x10494: file main.c, line 12.
(gdb) r
Starting program: /home/pi/minimal Examples/a.out
Breakpoint 1, main () at main.c:12
12 printf ("valide: %d. \nIP-Adresse: %d", valide, (*ipaddr).s_addr );
(gdb) print valide
$1 = 1
(gdb) print (*ipaddr).s_addr
Cannot access memory at address 0x0
(gdb)
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
int main ()
{
const char *name="201.23.23.44";
struct in_addr *ipaddr;
int valide;
valide = inet_aton (name, ipaddr);
printf ("valide: %d. \nIP-Adresse: %d", valide, (*ipaddr).s_addr );
return 0;
}