
#include <stdio.h>
#include <windows.h>
#include <wininet.h>

int main()
{

        int intCtrlID=0;
     HINTERNET hResource;
     LPSTR    lpszData;      // buffer for the data
     DWORD    dwSize;        // size of the data available
     DWORD    dwDownloaded;  // size of the downloaded data
     DWORD    dwSizeSum=0;   // size of the data in the textbox
     LPSTR    lpszHolding;   // buffer to merge the textbox data and buffer
     const char *foo=NULL;

hResource=InternetOpen("vws",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
  
hResource=InternetOpenUrl(hResource,
"http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=KCASANFR5&PASSWORD=sunfish&dateutc=2000-01-01+10%3A32%3A35&winddir=230&windspeedmph=12&windgustmph=12&tempf=70&rainin=0&baromin=29.1&dewptf=68.2&humidity=90&weather=&clouds=&softwaretype=vws%20versionxx&action=updateraw"
,foo,0,0,0);


     // This loop handles reading the data.  
     do
     {
          // The call to InternetQueryDataAvailable determines the amount
                  // of data available to download.
          if (!InternetQueryDataAvailable(hResource,&dwSize,0,0))
          {
                printf("ERR - InternetReadFile %s",GetLastError());
               return FALSE;
          }
          else
          {     
                // Allocate a buffer of the size returned by
                // InternetQueryDataAvailable.
               lpszData = new char[dwSize+1];

               // Read the data from the HINTERNET handle.
               if(!InternetReadFile(hResource,(LPVOID)lpszData,dwSize,&dwDownloaded))
               {
                   // ErrorOut(hX,GetLastError(),"InternetReadFile");
                    delete[] lpszData;
                    break;
               }
               else
               {
                    // Add a null terminator to the end of the data buffer.
                    lpszData[dwDownloaded]='\0';

                    // Allocate the holding buffer.
                    lpszHolding = new char[dwSizeSum + dwDownloaded + 1];
                    // Make the holding buffer an empty string. 
                    lpszHolding[0]='\0';


                    // Add the new data to the holding buffer
                    strcat(lpszHolding,lpszData);


                        printf("%s",lpszHolding);
                    // Delete the two buffers.
                    delete[] lpszHolding;
                    delete[] lpszData;

                    // Add the size of the downloaded data to the textbox data size.
                    dwSizeSum = dwSizeSum + dwDownloaded + 1;

                    // Check the size of the remaining data.  If it is zero, break.
                    if (dwDownloaded == 0)
                         break;
               }
          }
     }
     while(TRUE);

     // Close the HINTERNET handle.
     InternetCloseHandle(hResource);

     // Return
     return TRUE;
}




