Solved

Simple c program

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

729 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