Separate IP parts

brocolis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 9 19:51:34 PST 2016


How do I separate IP parts with dlang?

I found this very cool trick, with C++: 
http://stackoverflow.com/a/5328190

std::string ip ="192.168.1.54";
std::stringstream s(ip);
int a,b,c,d; //to store the 4 ints
char ch; //to temporarily store the '.'
s >> a >> ch >> b >> ch >> c >> ch >> d;
std::cout << a << "  " << b << "  " << c << "  "<< d;

I wonder what's the equivalent D code.




More information about the Digitalmars-d-learn mailing list