#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    How to read IP address from a text file in C


    How to read IP address from a text file and how to process the ip address and which data type is used to store the Ip address..
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Iran
    Posts
    149
    Rep Power
    139
    Take a look at Tutorial: C File I/O and Binary File I/O

    Also here is another example:

    http://stackoverflow.com/questions/3463426/in-c-how-should-i-read-a-text-file-and-print-all-strings

    Now, how you process the IP address depends on the structure of the data in your file.

    Regards,
    Dariyoosh
    Last edited by dariyoosh; February 25th, 2013 at 04:56 AM.
  4. #3
  5. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,110
    Rep Power
    1803
    IP V6 and V4 addresses have different formatting conventions and when stored as an address rather than a string, different data types to.

    inet_pton() converts an IPV4 and IPV6 addresses in "digits and dots" or "hex and colon" form to an in_addr or in6_addr structure.

IMN logo majestic logo threadwatch logo seochat tools logo