Solved

Simple c program

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 clear a vector as well as how to detect empty vectors in C++.

810 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