29.10.2014, 12:23
Hi
I was wondering, how could I change a specific character in a string, without having to reformat the entire string manually?
I tried using strins and strdel in order to do this:
Where PInfo[playerid][string] is the string that we are going to modify, charpos stands for the position of the character that we are going to change, and N stands for the new character that we are going to instert.
At first sight this seems to work, however everytime I try this, the string is properly modified but at the end of the string there's some random stuff added that has nothing to do with the string...
So for example if I were to modify the following string:
, and wanted to change it to this:
, I get this:
Does anyone know why this happens?
And is there a better way to modify a certain character in a string and keep the rest untouched?
Thanks in advance
I was wondering, how could I change a specific character in a string, without having to reformat the entire string manually?
I tried using strins and strdel in order to do this:
pawn Код:
strdel(PInfo[playerid][string], charpos, charpos + 1);
strins(PInfo[playerid][string], "N", charpos);
At first sight this seems to work, however everytime I try this, the string is properly modified but at the end of the string there's some random stuff added that has nothing to do with the string...
So for example if I were to modify the following string:
Код:
Hello
Код:
HelLo
Код:
HelLo Efsqaef
And is there a better way to modify a certain character in a string and keep the rest untouched?
Thanks in advance