I'm a beginner to programming. I keep getting this error as I run my program. I have already checked online and many people suggest to add /* #pragma comment(lib, "wininet.lib") */ after all the includes, or to change property setting.
I changed both so far, but the message is still there.
I'm using 2010 Microsoft Visual Studio and the entire error message is below:
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol WinMain@16 referenced >in function __tmainCRTStartup
1>C:\Users\Username\Desktop\Winlnet test\Debug\Winlnet test.exe : fatal error LNK1120: 1 >unresolved externals
1>
1>Build FAILED.
1>
any help is greatly appreciated!! below is the program.
#include <string>
#include <iostream>
#include <fstream>
#include <windows.h>
#include <wininet.h>
#include <winsock.h>
#include <stdio.h>
#include <stdarg.h>
#pragma comment(lib, "wininet.lib")
using namespace std;
int main()
{
HINTERNET hOpen, hURL;
LPCWSTR NameProgram = L"Webreader"; // LPCWSTR == Long Pointer to Const Wide String
LPCWSTR Website;
char file[101];
unsigned long read;
//Always need to establish the internet connection with this funcion.
if ( !(hOpen = InternetOpen(NameProgram, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 )))
{
cerr << "Error in opening internet" << endl;
return 0;
}
Website = L"http://www.google.com";
hURL = InternetOpenUrl( hOpen, Website, NULL, 0, 0, 0 ); //Need to open the URL
InternetReadFile(hURL, file, 100, &read);
while (read == 100)
{
InternetReadFile(hURL, file, 100, &read);
file[read] = '\0';
cout << file;
}
cout << endl;
InternetCloseHandle(hURL);
return 0;
}