Access Violation when accessing Dynamic Array

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 2 09:56:12 PST 2016


On Saturday, 2 January 2016 at 17:39:42 UTC, Jack wrote:
> So I'll just send the whole file if you don't mind:
>
> http://dpaste.com/11V5BYA (Line 174-183)
>
> The contents of the .txt file is :
> http://dpaste.com/3FVW5QR
>
> I just checked it and it compiles but it does that strange 
> Access Violation error.

By far the most likely explanation for an exception at that 
location, would be if `custom_keyword` really didn't contain a 
valid key into the `custom` associative array.

So, to check I added this code:
     writefln("custom_keyword: \"%s\"", custom_keyword);
     stdout.flush(); // This may be required if you're running the 
code inside an IDE.
     readln();
Right before `custom[custom_keyword]`.

This printed the following:
     custom_keyword: "Mario "
Notice the extra space at the end.

The solution is to use `strip()` rather than `stripLeft()`.


More information about the Digitalmars-d-learn mailing list