I am only beginning C but that still helped. Useful bit of code.
Okay so used the automation page/directory in the latter ip website.
As I have a separate .c file for finding the ip I need to pass it to the file that actually uses the ip in a format that can be used like this - to construct a socket:
Obviously needs changing a bit.
Code:
memset(&echoServAddr, 0, sizeof(echoServAddr)); /* Zero out structure */
echoServAddr.sin_family = AF_INET; /* Internet address family */
echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
echoServAddr.sin_port = htons(echoServPort); /* Local port */
Problem is I get a compile warning - and dont shoot me if this is a lame question, im new to c:
get_ip.c [Warning] return makes integer from pointer without a cast
Code:
char get_ip(void)
{
size_t sz;
char* file_contents = GetInternetFile(TEXT("http://www.whatismyip.com/automation/n09230945.asp"), 100, &sz);
return file_contents;
}