07.05.2012, 08:01
(
Последний раз редактировалось iggy1; 07.05.2012 в 08:04.
Причина: Fixed error (oops)
)
Here's a replace char func i haven't tested it, but it should be better than calling strlen ever iteration.
szString is passed by reference.
You could use it to replace other chars too.
pawn Код:
stock ReplaceChar( szString[] , chReplace = '_', chReplaceWith = ' ' )
{
new _itr = 0;
while( szString[ _itr ] != EOS )
{
if( szString[ _itr ] == chReplace ) szString[ _itr ] = chReplaceWith;
++_itr;
}
}
pawn Код:
new szStr[ 32 ] = "replace_underscores_pliz";
ReplaceChar( szStr );
printf( szStr );//should print "replace underscore please"
pawn Код:
new szStr[ 64 ] = "replace*asterix*pliz*with*underscore";
ReplaceChar( szStr, '*', '_' );
printf( szStr );//should print "replace_asterix_pliz_with_underscore"