First, compile with more warnings.
Code:
$ gcc -Wmissing-prototypes -Wall foo.c
foo.c: In function ‘main’:
foo.c:31:2: warning: implicit declaration of function ‘inet_ntoa’ [-Wimplicit-function-declaration]
foo.c:31:2: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
foo.c:15:8: warning: unused variable ‘gg’ [-Wunused-variable]
foo.c:28:15: warning: ‘addr’ may be used uninitialized in this function [-Wuninitialized]
Second, read the manual page. Note the feature macro necessary to expose the interface of inet_ntoa
Also note the header file arpa/inet.h which you are not including.
Quote Originally Posted by man
INET(3) Linux Programmer's Manual INET(3)

NAME
inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof - Internet address manipulation routines

SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int inet_aton(const char *cp, struct in_addr *inp);

in_addr_t inet_addr(const char *cp);

in_addr_t inet_network(const char *cp);

char *inet_ntoa(struct in_addr in);

struct in_addr inet_makeaddr(int net, int host);

in_addr_t inet_lnaof(struct in_addr in);

in_addr_t inet_netof(struct in_addr in);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

inet_aton(), inet_ntoa(): _BSD_SOURCE || _SVID_SOURCE
When the include is fixed, the call is fixed and compiled with the correct command line, I get
Code:
$ gcc -Wmissing-prototypes -Wall -D_SVID_SOURCE foo.c
foo.c: In function ‘main’:
foo.c:15:8: warning: unused variable ‘gg’ [-Wunused-variable]
foo.c:28:15: warning: ‘addr’ may be used uninitialized in this function [-Wuninitialized]