how can i convert the net_ntoa(server.sin_addr) to char

This is a discussion on how can i convert the net_ntoa(server.sin_addr) to char within the C Programming forums, part of the General Programming Boards category; hi all i can using the code to see my ip ? Code: printf("server :'%s'\n",inet_ntoa(server.sin_addr)); but how can i convert ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    how can i convert the net_ntoa(server.sin_addr) to char

    hi all
    i can using the code to see my ip ?
    Code:
    	printf("server :'%s'\n",inet_ntoa(server.sin_addr));

    but how can i convert the net_ntoa(server.sin_addr) to char inorder to save as string format ?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You need to ask a question that makes sense: if you wanted it as a string, you certainly can't convert it to char, since that's not what a string is.

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    6
    I'm sorry ! String is just explanation .
    I want to get the value of inet_ntoa(server.sin_addr) , so i want to save to char .
    so how can i conver the value of inet_ntoa(server.sin_addr) to char using C ?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You can't. It's not a char. You can save it to a char array, if you want, using strcpy.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  2. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  3. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  4. convert long to pointer to char array
    By gazmack in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2003, 11:33 AM
  5. Searching a linked list for char
    By spentdome in forum C Programming
    Replies: 3
    Last Post: 05-22-2002, 11:11 AM

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