Deleting Entries from an Array
Daniel Biehl
dbiehl at gmx.net
Wed Jun 27 02:57:52 PDT 2007
Hello,
I play a little bit with D to learn something more about it. One
interesting feature is splicing of arrays. I wrote a little function to
delete some entries from an array of chars. I thought it was easy, but I
only get a memory access error (Speicherzugriffsfehler in german) under
Linux with DMD 1.015 and gdc 0.24 and on Windows XP only with gdc 0.23.
Where is the Bug? Me or Phobos/DMD/GDC?
module tt;
import std.stdio;
char[] cut(inout char[] s, size_t index, size_t count) {
s[index..length - count] = s[index+count..length].dup;
s.length = s.length - count;
return s;
}
void main()
{
char[] s = "Hello World";
writefln(s.length);
writefln(s.cut(1,1));
writefln(s.length);
}
Greets Daniel
More information about the Digitalmars-d
mailing list