Hi all, I need some help here. I'm just learning.
This is what i have so far.
I am able to retrieve my wan ip address and use printf to display the full WANIP. But if I try to save it to a file all I get is: WAN IP: 2
I have linked the wininet lib, also
Any help here is greatly appreciated.
Code:#include <wininet.h> #include <stdio.h> #define AUTHOR "Oh" CHAR buffer[100]; int i=75; int main(int argc, char *argv[]) { HINTERNET hINet, hFile; CHAR buffer[100]; hINet = InternetOpen(AUTHOR, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ); if ( !hINet ) { printf("No Internet Connection"); } hFile = InternetOpenUrl( hINet,"http://checkip.dyndns.org/" , NULL, 0, 0, 0 ); if ( hFile ) { DWORD dwRead; InternetReadFile( hFile, buffer, 100, &dwRead ); } InternetCloseHandle( hFile ); InternetCloseHandle( hINet ); printf("WAN IP:"); while ((buffer[i] != 0x3C) && (i < sizeof(buffer))) { printf("%c",buffer[i]); i++; } getchar(); return 0; while ((buffer[i] != 0x3C) && (i < sizeof(buffer))) { FILE *pFile; pFile = fopen ("c:\\test.txt","w"); fprintf (pFile, "WAN IP: "); fprintf (pFile,"%c", buffer[i]); ++i; } return 0; }



LinkBack URL
About LinkBacks


