Re: Separate IP parts

2016-12-11 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 10 December 2016 at 03:51:34 UTC, brocolis wrote: How do I separate IP parts with dlang? I found this very cool trick, with C++: http://stackoverflow.com/a/5328190 Heh, I'd prefer to use sscanf vs using the streams.

Re: Separate IP parts

2016-12-11 Thread notna via Digitalmars-d-learn
On Saturday, 10 December 2016 at 13:25:13 UTC, Nicholas Wilson wrote: On Saturday, 10 December 2016 at 13:21:40 UTC, notna wrote: Those statements need to be inside a function. Feel free to post a working example or, even better, a pull request with one ;)

Re: Separate IP parts

2016-12-10 Thread aberba via Digitalmars-d-learn
On Saturday, 10 December 2016 at 13:25:13 UTC, Nicholas Wilson wrote: On Saturday, 10 December 2016 at 13:21:40 UTC, notna wrote: On Saturday, 10 December 2016 at 08:03:00 UTC, biozic wrote: [...] Well, you know, that's one of the not so great things about Dlang... you cannot even trust

Re: Separate IP parts

2016-12-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 December 2016 at 13:21:40 UTC, notna wrote: On Saturday, 10 December 2016 at 08:03:00 UTC, biozic wrote: [...] Well, you know, that's one of the not so great things about Dlang... you cannot even trust the provided examples, if there are any: [...] Those statements

Re: Separate IP parts

2016-12-10 Thread notna via Digitalmars-d-learn
On Saturday, 10 December 2016 at 08:03:00 UTC, biozic wrote: This would do the same. I wouldn't say it's a trick. import std.format : formattedRead; import std.stdio : writefln; string ipAddr = "192.168.1.54"; int a, b, c, d; formattedRead(ipAddr, "%d.%d.%d.%d", , , , );

Re: Separate IP parts

2016-12-10 Thread biozic via Digitalmars-d-learn
On Saturday, 10 December 2016 at 03:51:34 UTC, brocolis wrote: 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 in

Re: Separate IP parts

2016-12-09 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 10 December 2016 at 03:51:34 UTC, brocolis wrote: 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 in

Separate IP parts

2016-12-09 Thread brocolis via Digitalmars-d-learn
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 >>