Filling a char array with letters and element type of char[]
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 3 11:48:31 PST 2015
On 03/03/2015 11:38 AM, Steven Schveighoffer wrote:
> Sure, but I think that for phobos to say you can't fill a large char[]
> with a repeat of small char[], but you can fill a large int[] with a
> repeat of small int[], is more of a problem than somehow fixing the
> underlying situation.
>
> Other algorithms treat char[] specially. fill should too.
std.string.representation works in this case.
import std.stdio;
import std.algorithm;
import std.string;
void main()
{
char[] strArr = "http://www.hurriyet.com.tr/ekonomi".dup;
auto domain = findSplitAfter(strArr.representation,
"http://")[1].until('/');
fill(domain, 'a');
writeln(strArr);
}
Prints
http://aaaaaaaaaaaaaaaaaaa/ekonomi
Ali
P.S. Grrr. Why can't I ever remember the name of that function!
(representation, representation, representation, ...)
More information about the Digitalmars-d-learn
mailing list