Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

Saturday, October 16, 2010

inet_ntoa() segmentation fault issue

inet_ntoa is a UNIX system call used in socket programming to obtain an IPv4 string form of an IP address from its in_addr form.

I have encountered an issue where its use results in the following warning:

warning: assignment makes pointer from integer without a cast

Attempting to run a program with this warning on inet_ntoa will result in a segmentation fault.

The cause of the problem is not incorrect C, but a missing header file. Shachar Shemesh wrote that the solution to this obscure problem is simply to include the arpa/inet.h header file:

#include <arpa/inet.h>