First, #include <arpa/inet.h>, which is needed for inet_ntop().

You need to treat the struct sockaddr as the proper type, by casting it. Example:
Code:
inet_ntop(res->ai_family, &((struct sockaddr_in *)res->ai_addr)->sin_addr, addrstr, 100);
res->ai_addr->sa_data doesn't contain anything useful, as far as you're concerned. It's just an opaque bunch of data that is used by the “subtypes” of struct sockaddr to store address data. How that address data is stored is up to the subtype.