Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. UrlDownloadToFile() equivalent for linux?

UrlDownloadToFile() equivalent for linux?

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ALLERSLIT
    wrote on last edited by
    #1

    Hey, Iam looking for a function i could use that is just as easy to use as UrlDownloadToFile() on windows. C or C++ doesnt matter. Thanks.

    M M 2 Replies Last reply
    0
    • A ALLERSLIT

      Hey, Iam looking for a function i could use that is just as easy to use as UrlDownloadToFile() on windows. C or C++ doesnt matter. Thanks.

      M Offline
      M Offline
      markkuk
      wrote on last edited by
      #2

      libcurl[^]

      A 1 Reply Last reply
      0
      • M markkuk

        libcurl[^]

        A Offline
        A Offline
        ALLERSLIT
        wrote on last edited by
        #3

        Iam aware of curl, its not as easy to use as UrlDownloadToFile().

        A 1 Reply Last reply
        0
        • A ALLERSLIT

          Iam aware of curl, its not as easy to use as UrlDownloadToFile().

          A Offline
          A Offline
          Aescleal
          wrote on last edited by
          #4

          It may not be as easy to use but on the CURL website there's a simple HTTP[^] client in about 6 lines. Open a file to write to and use CURLOPT_WRITEDATA and snip snip, bob's your Aunty:

          #include <stdio.h>
          #include <curl/curl.h>

          int main(void)
          {
          CURL *curl = curl_easy_init();
          FILE *output_to = fopen( "output.txt", "w" );

          if( curl && output_to )
          {
          curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se" );
          curl_easy_setopt(curl, CURLOPT_WRITEDATA, output_to );
          curl_easy_perform(curl);
          }

          if( curl ) curl_easy_cleanup(curl);
          if( output_to ) fclose( output_to );
          }

          Bundle that lot up in a function and you're done... Cheers, Ash PS: There's no error reporting if the transfer goes pear shaped PPS: I haven't programmed in C in years and not having cURL handy on my home computer I haven't checked the code compiles and runs but it's not far off

          1 Reply Last reply
          0
          • A ALLERSLIT

            Hey, Iam looking for a function i could use that is just as easy to use as UrlDownloadToFile() on windows. C or C++ doesnt matter. Thanks.

            M Offline
            M Offline
            Moak
            wrote on last edited by
            #5

            Search for a C++ library offering a HTTP client[^], see if it helps.

            Chat in Europe :java: Now with 24% more Twitter

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups