[Issue 1716] Access Violation at readln
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 9 00:46:36 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1716
matti.niemenmaa+dbugzilla at iki.fi changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Keywords|EH |
Resolution| |INVALID
------- Comment #8 from matti.niemenmaa+dbugzilla at iki.fi 2008-03-09 03:46 -------
The problem is line 21:
FILE* file = fopen(cast(char*)filename, "r");
You can't just cast a char[] to a char* like that. C functions like fopen
expect a terminating null character in every string, and your char[] doesn't
have one.
The correct way to do this is to convert it to a null-terminated string:
FILE* file = fopen(toStringz(filename), "r");
--
More information about the Digitalmars-d-bugs
mailing list