|
|
| Author |
Message |
< Erlang ~ list_to_string ? |
| klm |
Posted: Sat May 23, 2009 10:16 pm |
|
|
|
User
Joined: 11 May 2009
Posts: 18
|
hey !
I've got a question.
I have an Ip address and I try to change it into a string to send it into a message
{ok,Name} = inet:gethostname(),
{ok,Addr} = inet:getaddr(Name,inet),
Message = "My Ip" ++ Addr,
io:format("Test : ~p",[Message]),
it's just an example but it's to show what's my problem
I can't concatenate a string and an Ip address ( with the form {192,168,1,1} )
I try to do a tuple_to_list(Addr), but I can't also concatenate a list and a string.
how can I do a string contening the address ?
thanks ! |
|
|
| Back to top |
|
| ates |
Posted: Sat May 23, 2009 10:52 pm |
|
|
|
Joined: 23 May 2009
Posts: 3
|
Use inet_parse:ntoa(IP)
IP = {1,1,1,1}.
Msg = "My IP: " ++ inet_parse:ntoa(IP).
io:format("~p~n", [Msg]). |
|
|
| Back to top |
|
| klm |
Posted: Sun May 24, 2009 3:46 pm |
|
|
|
User
Joined: 11 May 2009
Posts: 18
|
ok thanks
I didn't knew this function, I will try it
I had found another solution with io_lib:format("~p",[Ip]), |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|