Follow us on Twitter!
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill
Wednesday, February 10, 2016
Navigation
Home
 Find:
 Information:
Learn
Communicate
Submit
Shop
Challenges
 Exploit:
 Programming:
 Think:
 Track:
 Patch:
 Other:
 Need Help?
Other
Members Online
Total Online: 28
Guests Online: 26
TeamSpeak Online : 5 Members Online: 2

Registered Members: 92293
Newest Member: mirookers
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

downloading files in c++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 07-03-06 20:49
I have just started learning c++. I have the Dev-c++ compiler. What code would I need to connect to a web/ftp server and download files?


Author

RE: downloading files in c++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 07-03-06 20:51
Google beej's guide to sockets. It's invaluable.


Author

RE: downloading files in c++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 07-03-06 21:03
In python this would do it.
Code

#!/usr/bin/python
import urllib
url=raw_input('File to download: '
a=urllib.urlopen(url).read()
save=raw_input('Save as... ')
b=open(save, 'w')
b.write(a)
b.close()
a.close()





I expect its the same, basically open a webpage and read it, will do html just as it does .exe so long as .exe is saved as .exe and html as .html you'll be fine.


Author

RE: downloading files in c++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 08-03-06 01:18
wolfmankurd wrote:
In python this would do it.
Code

#!/usr/bin/python
import urllib
url=raw_input('File to download: '
a=urllib.urlopen(url).read()
save=raw_input('Save as... ')
b=open(save, 'w')
b.write(a)
b.close()
a.close()





I expect its the same, basically open a webpage and read it, will do html just as it does .exe so long as .exe is saved as .exe and html as .html you'll be fine.


Actually, it's the same, but with a lot more coding. For C++, you need to learn sockets, and I can vouch for Beej's guide. It's quite good.

Beej's Guide to Sockets