char get_buffer[10000];
SSL_write(conn,https_request_get,strlen(https_request_get));
printf("GET Sent...\n");
byte_count = SSL_read(conn,get_buffer,sizeof(get_buffer));
printf("recv()'d %d bytes of data in get_buff\n",byte_count);
printf("%s",get_buffer);
fprintf(html, "%s",get_buffer);
fwrite(get_buffer,sizeof(get_buffer),1,html); //html is the file pointer
I've written a C program with sockets that "downloads" the landing page HTML of a given website from the HTTP response. I was able to store the entire HTTP response in a char array and was also able to print it in the console using printf("%s",buffer_name)
.
Now I am trying to write the same array into a file ( fprintf()
), but it only prints the HTTP response excluding the HTML of the page. I understand that there can be null characters and I also tried
fwrite(buffer,sizeof(buffer),1,file_ptr)
which gave me the same output as before (didn't put HTML into the file).
Can anyone help me out with this ?