[SDL] convert IPaddress to string

Alan Wolfe Atrix2 at cox.net
Mon Jul 17 15:28:04 PDT 2006


Char Buffer[256]

sprint(Buffer,"%i.%i.%i.%i",byte1,byte2,byte3,byte4);

I don't know the structure member names but that'd be a decent way to do it

-----Original Message-----
From: sdl-bounces+atrix2=cox.net at libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of Roger D. Vargas
Sent: Monday, July 17, 2006 3:25 PM
To: SDL at libsdl.org
Subject: Re: [SDL] convert IPaddress to string

El lun, 17-07-2006 a las 12:12 -0700, 1337p337 escribió:
> On 17/07/06, Roger D. Vargas <roger at ehtsc.co.cu> wrote:
> > What is the best way to convert the host member of IPaddress struct to a
> > printable string?
> 
> There doesn't seem to be a function for this in SDL_Net (looking
> briefly over the docs), but you could probably get away with
> sprintf(ip_string, "%s", inet_ntoa((struct in_addr) ip.host);
> 
> Make sure to include sys/socket.h, netinet/in.h, and arpa/inet.h.
> Hope that helps.
> ]
Is tha portable? I was thining in something like decomposing the int in
four bytes and printing them in the string.

> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
-- 
Roger D. Vargas <roger at ehtsc.co.cu>
Formatur Santiago


_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl





More information about the SDL mailing list