The following program demonstrates how you might use the getnameinfo C library call to perform a DNS PTR query that resolves an IP address into the canonical domain name. The program is invoked as:
./getnameinfo IP