String copying fails when output from assert

David Zhang straivers98 at gmail.com
Tue Nov 21 18:49:40 UTC 2017


Hi,

I've been trying to copy a string, then output it from an 
`assert(false)` statement, but the copy seems to be corrupted 
somehow.

void main()
{
	string str = "some string";

         //initializing `chars` with any value doesn't do anything
	char[64] chars;
	//char[64] chars = '!';

	//memcpy doesn't work either, though the output's different
	//import core.stdc.string;
	//memcpy(&chars[0], &str[0], str.length);

	chars[0..str.length] = str;
	assert(false, chars[0..str.length]);
}

What am I missing here?



More information about the Digitalmars-d-learn mailing list