Math a string (?)
#7

Quote:
Originally Posted by Dwane
Посмотреть сообщение
There is a way.

pawn Код:
// Normal split function, I just added a second delimiter
stock split(const strsrc[], strdest[][], delimiter1, delimiter2)
{
    new i, li;
    new aNum;
    new len;
    while(i <= strlen(strsrc))
    {
        if((strsrc[i] == delimiter1 || strsrc[i] == delimiter2)|| i == strlen(strsrc))
        {
            len = strmid(strdest[aNum], strsrc, li, i, 128);
            strdest[aNum][len] = 0;
            li = i+1;
            aNum++;
        }
        i++;
    }
    return 1;
}
pawn Код:
main( )
{
    new
        maths_text[ 15 ],
        number_coords[ 3 ][ 3 ],
        tmpstr[ 32 ]
    ;
    format( maths_text, sizeof( maths_text ), "18-1+8" );
    split( maths_text, number_coords, '+', '-' );
    format( tmpstr, sizeof( tmpstr ), "maths: a = %s, b = %s, c = %s", number_coords[ 0 ], number_coords[ 1 ], number_coords[ 2 ] );
    print( tmpstr );
}
pawn Код:
// Output:
[23:14:36] maths: a = 18, b = 1, c = 8
thank you so much !!!!!!!!!!!!!!!!!!!!!!!!
Reply


Messages In This Thread
Math a string (?) - by Salim_Karaja - 18.03.2013, 20:18
Re: Math a string (?) - by mastermax7777 - 18.03.2013, 20:20
Re: Math a string (?) - by Salim_Karaja - 18.03.2013, 20:21
Re: Math a string (?) - by Rock - 18.03.2013, 20:21
Re: Math a string (?) - by Misiur - 18.03.2013, 20:24
Re: Math a string (?) - by Konstantinos - 18.03.2013, 20:50
Re: Math a string (?) - by Salim_Karaja - 18.03.2013, 21:12
Re: Math a string (?) - by Konstantinos - 18.03.2013, 21:20
Re: Math a string (?) - by Misiur - 18.03.2013, 21:50
Re: Math a string (?) - by mastermax7777 - 18.03.2013, 22:52

Forum Jump:


Users browsing this thread: 1 Guest(s)