xcode / gethostbyname()?

Discussion in 'Mac Programming' started by aosmith, Mar 20, 2010.

  1. aosmith macrumors newbie

    Joined:
    Feb 9, 2007
    #1
    SOLVED (It's my typo not xcode)
    Code:
    char *test = "acenusm.com";
    hostptr = gethostbyname(test); 
    printf("Host: %s\n", inet_ntoa(hostptr->h_addr));
    
    (and a screen shot because it is legal code)

    [​IMG]

    Any ideas?
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Try hostent instead of hosten for hostptr.

    Edit: Looks like you found it.

    -Lee
     
  3. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #3
    It shows a principle that applies so often: Don't ask what's wrong with your compiler, or with your libraries, ask what is wrong with your code. The most common wrong assumption is the assumption that your own code is correct.

    It also demonstrated nicely the need to post _complete_ source code, not the stuff that you think is important.
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    this is something I run into all the time at work. The senior-most member of my team would blame crashes on "runtime" problems, "heap mismatches", etc. There are certainly times that there will be a compiler or runtime problem (I have had to fix a couple), but my first assumption is always something terrible in our code causing the problem. I need overwhelming evidence to believe that the issue lies elsewhere.

    -Lee
     

Share This Page