www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [your code here]

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;
}
May 11 2019