Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ifstream help needed...

Status
Not open for further replies.

eyesrglazed

Programmer
Jul 14, 2005
20
0
0
US
I am trying to input from a file on the Internet, although I'm not sure if this is possible. Any ideas?
 
Not with just an [tt]ifstream[/tt], it isn't.

A file "on the Internet" can mean lots of things. If you mean "on the Web," then you'll need to use a library that knows HTTP (the protocol used to retrieve objects from the Web). You may have such a library already on your system, or you may need to grab one like libcurl, which can incidentally be used to retrieve files using other Internet protocols as well.
 
Okay. So what would I include for that if my code was something simple like this :

Code:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main
{
    ifstream inFile;
    string   webSite;
    string   str;

    cin >> webSite;
    inFile.open(webSite.c_str());
    inFile >> str;
    cout << str;

    return 0;
}

I would like to know what else I need for this to be able to use an actual website where the variable webSite is.

What would the resulting code look like?
 
See WinInet API (InternetOpenUrl, HttpOpenRequest, FtpOpenFile, InternetReadFile etc)...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top