PDA

View Full Version : how to delete some chars from string?


neatek
02-19-2012, 15:18
how to delete some chars from string?
For example: PHP - http://ru2.php.net/manual/en/function.substr.php

McFlurry
02-19-2012, 15:48
stock StringSubString(const String:input[], startindx, endindx, String:dest[], maxlength)
{
Format(dest, maxlength, input[startindx]);
if(strlen(input) > endindx)
{
ReplaceString(dest, maxlength, input[endindx], "");
}
}
The input can be the same as the dest.

berni
02-20-2012, 05:43
how to delete some chars from string?
For example: PHP - http://ru2.php.net/manual/en/function.substr.php

Sourcepawns strings don't work like in PHP.
If you just want to cut some chars at the end of the string the most efficient way is:

string[x] = '\0';

where x is the position where to cut.