Solved

Simple c program

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

759 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