inet_addr()

This is a discussion on inet_addr() within the C Programming forums, part of the General Programming Boards category; Hello World! When i call inet_addr(string containing vaild ip address), i get back int back. Like: Code: printf("%d\n", inet_addr("192.168.0.1")); /* ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Location
    Denmark
    Posts
    22

    inet_addr()

    Hello World!

    When i call inet_addr(string containing vaild ip address), i get back int back.
    Like:

    Code:
    printf("%d\n", inet_addr("192.168.0.1"));
    
    /* The result is: 16820416 */
    What does the decimals mean and why convert the address ?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Apparently it is an internet address. http://www.opengroup.org/onlinepubs/...inet_addr.html
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    16820416 = 0x0100A8C0
    Broken down into 4 bytes (network-order, or big-endian):
    0x01, 0x00, 0xA8, 0xC0
    Or
    1, 0, 168, 192

    Windows reference: http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx

    gg

  4. #4
    Registered User
    Join Date
    Jul 2008
    Location
    Denmark
    Posts
    22
    Thx...

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21