www.digitalmars.com         C & C++   DMDScript  

D - reference counter trouble

reply kw <kw_member pathlink.com> writes:
int main (char[][] args)
{
char[] a = "a", q = a;

printf("a=%.*s, q=%.*s\n", a, q);
a = "b";
printf("a=%.*s, q=%.*s\n", a, q);
return 0;
}

prints

a=a, q=a
a=b, q=a

Change the a = "b" by an a[0]++, now it prints

a=a, q=a
a=b, q=b  <== q should be "a"
Sep 07 2003
parent kw <kw_member pathlink.com> writes:
a=a, q=a
a=b, q=a
[...] Oops. Just found it arrays.html / Array Copying
Sep 07 2003