Long story short, I'm using curl to download a file off my site. I've done tests and successfully downloaded a few txt files.

The main point, though, is to download an exe file. So I uploaded the exe file to my site, and downloaded it straight from my browser with no problems, and the exe ran fine. But when I tried downloading it with the curl program, it downloaded, yet exe was corrupt and crashed on start.

Any ideas from you smart guys? my theory is maybe its not downloading it binary-wise or something confusing like that. Any solutions? Thanks


#include <curl/curl.h>
#include <cstdio>
void get_page( const char* url, const char* file_name )
  CURL* easyhandle = curl_easy_init() ;
  curl_easy_setopt( easyhandle, CURLOPT_URL, url ) ;
  std::FILE* file = std::fopen( file_name, "w" ) ;
  curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, file ) ;
  curl_easy_perform( easyhandle );
  curl_easy_cleanup( easyhandle );
int main()
  get_page( "http://*********.com/game.exe",
            "testfile.exe" ) ;

Edited by mybluehair: n/a

7 Years
Discussion Span
Last Post by GhostfromTexas

std::FILE* file = std::fopen( file_name, "w" ) ;

You need to change the "w" to a "wb" which will make it a binary operation

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.