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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open the content of a document located in the internet.

Status
Not open for further replies.

lukelukeluke

Technical User
Dec 23, 2003
117
CH
Hi there.
I begun with C++ a few days ago.
I found/modified this script to open a file on the computer. It works very fine, actually, it opens the file "test.txt" and displays its content into the commandline.
But what i wanted to do was displaying a content of a file located on my website. I got a file on my website ( displaying the remote (your) ip adress. I wanted to create an application which shows the content of this ip file into the commandline.
Thanks alot for your help!

Here is my source code:
Code:
#include <stdio.h>
int main()
{
   FILE * pFile;
   char string [100];
   [aqua]//[URL unfurl="true"]http://www.lookass.ch/src/clientip.php[/URL][/aqua]
   [aqua]//test.txt[/aqua]
   pFile = fopen ("[navy]test.txt[/navy]" , "r");
   if (pFile == NULL) perror ("Error opening file");
   else {
     fgets (string , 100 , pFile);
     puts (string);
     fclose (pFile);
   }
   [aqua]//system("PAUSE");[/aqua]
   return 0;
}

any ideas of how to show the file on the web?
Thanks alot, help is very appreciated!

Webmaster of knowledgebase for IT knowledge.
 
If you want to do it the easy way and don't care if it runs on Windows only, try using some of the MFC classes like CHttpFile.
There should be plenty of examples of how to use it on the web.
 
You can also use winsock to do this without too much difficulty (unless you have a router, in which case I'm not sure how to do it).
 
i would like to make it work cross platform..
i have to add a thing that makes it go through the proxy too, right?

Webmaster of knowledgebase for IT knowledge.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top