[your code here]

Hello hello at world.com
Sat May 11 23:08:16 UTC 2019


uint buildIP(ubyte a, ubyte b, ubyte c, ubyte d)
{
     uint r = 0;
     r  = a << 24;
     r |= b << 16;
     r |= c << 8;
     r |= d;
     return r;
}

string toString(uint ip)
{
     import std.conv : to;
     string s;

     s ~= to!string(ip >> 24) ~ ".";
     s ~= to!string(0xff & ip >> 16) ~ ".";
     s ~= to!string(0xff & ip >> 8) ~ ".";
     s ~= to!string(0xff & ip);
     return s;
}

void main()
{
     import std.stdio;
     auto ip = buildIP(222, 31, 224, 172);
     toString(ip).writeln;
}



More information about the Digitalmars-d mailing list