Solved

Simple c program

Posted on 2007-03-20
5
188 Views
Last Modified: 2010-04-01
In the C programming language, how do I download an HTTP file using the url to the file?
Link to a simple example program would be nice, I did search, but I cant find it.

Do I use the same method for HTTPS pages?

0
Comment
Question by:Titanium_Sniper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 18756893
Take a look at libcurl :

http://curl.haxx.se/libcurl/

There's alot of documentation and examples on how to use it.
It supports HTTP, HTTPS and much more.
0
 
LVL 6

Expert Comment

by:_iskywalker_
ID: 18756919
you can use external programs like wget:
char * command[1024];
sprintf(command,"wget \"%s\"",myurl);
system(command);
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 18758786
If you are on Windows, a simple

#include <urlmon.h>

URLDownloadToFile(NULL,"http://www.sample.com/path/file.zip","c:\\tmp\\file.zip",0,NULL);

will do (also for HTTPS).

I'd recommend against launching external programs using 'system()' simply for the console window that will pop up.
0
 
LVL 5

Author Comment

by:Titanium_Sniper
ID: 18759507
Almost forgot,
I am going to be downloading from certain websites to record historical data from them and make my own personal version that has all the data they have put on the internet, (Newegg historical prices for one).
0
 
LVL 86

Expert Comment

by:jkr
ID: 18759557
I don't think that makes a difference...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question