char arrays

Saaa empty at needmail.com
Mon Jan 28 18:33:46 PST 2008


After quite a long thread in .learn here is what I learned:
(including a question :)

D1

string literal=Stored it in the code segment (read-only on unix)

char[] c=`string literal`;
char[14] c2=`string literal`;
char[] c3;    //heap: dynamic array of chars
char[10] c4;    //stack: static array(10) of chars
char[] c5=`heap: dynamic array of chars `.dup;
char[28] c6=`stack: static array(28) of chars `.dup;

char[] c7=c;    //c7 data points to the string literal of c
char[] c8=c.dup;    //c8=dynamic array of chars on heap

char[][] c9;    //heap: dynamic array of arrays of chars;
char[10][5] c10;    //stack: static array(5) of arrays(10) of chars;

char[4][5] c11=[`onee`,`twoo`,`thre`,`four`,`five`];    //string literals?
char[][] c12=[`one`,`two`,`three`,`five`,`six`];    //string literals?

This example is wrong:
char[] str;    //str is not a string literal
char[] str1 = "abc";
str[0] = 'b';        // error, "abc" is read only, may crash 





More information about the Digitalmars-d mailing list