Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to connect to multiple sites using C

wh92wh92 Posts: 1Member
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!!
Sign In or Register to comment.