07.12.2011, 13:34
(
Последний раз редактировалось leong124; 07.12.2011 в 14:17.
)
Hi, I found that if I do cell operations on strings, they cannot be cleared unless you loop through the string and clear cell-by-cell.
Output:
As you can see, neither x = "" and x[0] = '\0' can clear the string. It is reasonable for the latter to be unable to do so because it only clear the first cell to fake functions like strlen to think it is cleared, but x = "" should work.
So what's the problem with deleting the string?
pawn Код:
new x[16];
x[0] = '1';
x[1] = '2';
x[2] = '3';
x[3] = '4';
x[4] = '5';
printf("%d %s",strlen(x),x);
x = "";
x[0] = '2';
x[1] = '3';
x[2] = '4';
printf("%d %s",strlen(x),x);
x[0] = '\0';
x[0] = '5';
x[1] = '6';
printf("%d %s",strlen(x),x);
for(new i = 0;i < sizeof(x);i++) x[i] = '\0';
x[0] = '9';
printf("%d %s",strlen(x),x);
Код:
5 12345 5 23445 5 56445 1 9
So what's the problem with deleting the string?