Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

downloading files in c++


ghost's Avatar
0 0

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?


ghost's Avatar
0 0

Google beej's guide to sockets. It's invaluable.


ghost's Avatar
0 0

In python this would do it.

#!/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.


ghost's Avatar
0 0

wolfmankurd wrote: In python this would do it.

#!/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