A problem about strings
#8

kinda made up a scenario in my head about a dynamic string based on some variables, personally I'd just use another string but I came up with this script if I had to use the same string.

pawn Код:
new x[16];
    for(new i;i<10;i++)
    {
        switch(i)
        {
            case 1, 3, 5, 7, 9: x[i] = '1';
            default: x[i] = '0';
        }
    }
    print(x);
    x[0] = '\0';
    for(new i;i<5;i++)
    {
        switch(i)
        {
            case 1, 3, 5, 7, 9: strins(x,"3",i,sizeof(x));
            default: strins(x,"2",i,sizeof(x));
        }
    }
    print(x);
result:
0101010101
23232

not sure if it'd be faster than making all the cells null
Reply


Messages In This Thread
A problem about strings - by leong124 - 07.12.2011, 13:34
Re: A problem about strings - by TheArcher - 07.12.2011, 13:36
Re: A problem about strings - by leong124 - 07.12.2011, 13:39
Re: A problem about strings - by TheArcher - 07.12.2011, 13:41
Re: A problem about strings - by leong124 - 07.12.2011, 14:10
Re: A problem about strings - by JamesC - 07.12.2011, 14:19
Re: A problem about strings - by leong124 - 07.12.2011, 14:24
Re: A problem about strings - by cessil - 07.12.2011, 14:54
Re: A problem about strings - by cod4esle - 07.12.2011, 14:55
Re: A problem about strings - by leong124 - 07.12.2011, 15:49

Forum Jump:


Users browsing this thread: 4 Guest(s)