[HELP] NAME SURNAME without _
#10

Here's a replace char func i haven't tested it, but it should be better than calling strlen ever iteration.

pawn Код:
stock ReplaceChar( szString[] , chReplace = '_', chReplaceWith = ' ' )
{
    new _itr = 0;
       
    while( szString[ _itr ] != EOS )
    {
   
        if( szString[ _itr ] == chReplace ) szString[ _itr ] = chReplaceWith;
       
        ++_itr;
   
    }

}
szString is passed by reference.

pawn Код:
new szStr[ 32 ] = "replace_underscores_pliz";

ReplaceChar( szStr );

printf( szStr );//should print "replace underscore please"
You could use it to replace other chars too.

pawn Код:
new szStr[ 64 ] = "replace*asterix*pliz*with*underscore";

ReplaceChar( szStr, '*', '_' );

printf( szStr );//should print "replace_asterix_pliz_with_underscore"
Reply


Messages In This Thread
[HELP] NAME SURNAME without _ - by KaioBourne - 06.05.2012, 21:07
Re: [AJUDA] NOME SOBRENOME sem o _ - by Catalyst- - 06.05.2012, 21:17
Re: [AJUDA] NOME SOBRENOME sem o _ - by SuperViper - 06.05.2012, 22:47
Re: [HELP] NAME SURNAME without _ - by KaioBourne - 06.05.2012, 23:23
Re: [HELP] NAME SURNAME without _ - by blewert - 06.05.2012, 23:33
Re: [HELP] NAME SURNAME without _ - by KaioBourne - 06.05.2012, 23:50
Re: [HELP] NAME SURNAME without _ - by JaTochNietDan - 06.05.2012, 23:53
Re: [HELP] NAME SURNAME without _ - by KaioBourne - 07.05.2012, 00:07
Re: [AJUDA] NOME SOBRENOME sem o _ - by Kudoz - 07.05.2012, 06:25
Re: [HELP] NAME SURNAME without _ - by iggy1 - 07.05.2012, 08:01

Forum Jump:


Users browsing this thread: 3 Guest(s)