15.11.2011, 08:09
Quote:
I found a little problem with strdel, it seems like it just sets the pos cell to '\0' and still leaves the rest.
Because I was writing a function and in it, it looped backwards through a string to find the last of something, and even though strdel had supposedly deleted from pos 40 it still found the character after this position. I did a quick print test and deleted part of a string str[20]; str = "a string that's 20."; strdel(str, 10, 20); Then printed the remaining part, that was supposed to be deleted: print(str[11]); "hat's 20." So I made my own version that loops from the start to end and sets them all to 0. Not sure if this is a function bug or I have a crappy version defined somewhere. |
pawn Код:
new test[] = {'h', 'e', 'l', 'l', 'o', 0, 'w', 'o', 'r', 'l', 'd'};
print(test);
Deleting after the 0 is pretty much useless and inefficient (unless you're planning to use the array for something other than strings).