I'm trying to create a SIMPLE C++ program that uses a simple function to access the web and download a given URL that contains a file or HTML code. I want to use functions from header files that are contained in the windows.h header file. I do not want to download a new library from the internet. I don't want fancy stuff I want a function with the following prototype that contains the URL of the page to be accessed, the data array that will contain the HTML code on that web page
Int function( char URL, char data );
The function returns the size of the data contained in data. Returns -1 for error
This is learning how to do socket programming on windows. Since if you want a raw data stream from a HTML server you will need to open a socket to it and parse the HTML yourself. Libraries make this job much easier since there is so much to HTML to find one hyperlink in it. The socket would allow me to store an entire page in raw form to a file or array of data, though many pages may contain other scripting data in it for page formation.
I hope this is some food for thought. This program is not a simple one by any means. I don't think you will find anyone to write the code for you if you did not know the first basic steps to getting to the desired information.
As you're talking about using Win32 calls, there is also the Windows Internet (WinINet) API.
But you will have to include a Windows SDK headers in addition to windows.h; wininet.h for WinINet or winsock2.h, if you decide to use the Windows Sockets version 2 (WinSock2) API as Azagaros mentioned.
And there is no single function of the form int function( char URL, char data ); -- you'll have to create one yourself using WinInet, WinSock2, or a third-party library's functions.
(cURL is a popular open source library for HTTP, etc. Their site also provides a good list of their competitors (their word), including WinINet amonst several others: Other HTTP/FTP client Libraries http://curl.haxx.se/libcurl/competitors.html )
This thread from last year might be of interest; in particular, the code in WebJose's response includes a function which is almost what you want. You could alter DownloadBytes so it uses your function signature.
And have the function return 0 for success or an error code on failure (obtained using the Win32 GetLastError() function). The amount of data read is returned via the pDataRead param (which is a pointer rather than a reference so its use is optional.)