Solved

Simple c program

Posted on 2007-03-20
5
181 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

912 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now