Hi,
I'm a begginer in C so need a lil help with how to connect to multiple sites in C language.
I read a website from another file and then connect to it. Here is my code:
#include #include #include int main()
{
HINTERNET Initialize,Connection,File;
DWORD dwBytes;
char ch;
static const char filename[] = "webs.txt";
FILE *file = fopen ( filename, "r" );
if ( file != NULL ){
while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */{
fputs ( line, stdout ); /* write the line */
Connection = InternetConnect(Initialize,""&line,INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
File = HttpOpenRequest(Connection,NULL,"/index.html",NULL,NULL,NULL,0,0);
if(HttpSendRequest(File,NULL,0,NULL,0)){
while(InternetReadFile(File,&ch,1,&dwBytes)){
if(dwBytes != 1)break;
putchar(ch);
}
}
InternetCloseHandle(File);
InternetCloseHandle(Connection);
InternetCloseHandle(Initialize);
}
fclose ( file );
}
else{
perror ( filename ); /* why didn't the file open? */
}
return 0;
}
basically im getting the error at the "&line" in the initialization of the connection. Please help!!