indirections online?

Discussion in 'Mac Programming' started by Darkroom, May 28, 2008.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    so i'm learning about indirections, and i'd like to know how i may change the following code to obtain the .txt file from the internet instead of from my desktop.

    PHP:
    #import <Foundation/Foundation.h>

    int main (int argc, const char argv[])
        {
        
        
    FILE *textFile fopen ("/Users/me/Desktop/textFile.txt""r");
        
    char word[100];
        
        while (
    fgets(word100textFile))
            {
            
    word[strlen(word) - 1] = '\0';
            
    NSLog (@"%s is %d characters long"wordstrlen(word));
            }
            
        
    fclose (textFile);
        return (
    0);
        }
    simply changing the file's address to an http address doesn't work.

    any thoughts?
     
  2. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #2
    fopen() doesn't work with HTTP addresses. You need to use a socket, instead, to connect to the remote resource.

    Google search results for "C sockets" - that should give you some helpful tips on how to use them.
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #3
    thanks! :)
     

Share This Page