save text under several conditions
#4

Yes you need a loop, just check in it if the name already got added
If it doesnt add the new name to a free space, done

The code below is just an example

pawn Код:
stock AddToData(data[][], input[], i = sizeof data, const size = sizeof data[])
{
    if(!input[0]) return 0; //checks if the input is emtpy
    new free = -1; //declares free as -1
    while((--i) != -1) //A while loop
        if(!data[i][0]) free = i; //Checks if the data space is emtpy - necessary because of strcmp
        else if(!strcmp(input, data[i], true)) return 0; //Checks if the name is the same
    if(free == -1) return -1; //returns -1 if no free space was found
    strcat(data[free], input, size); //insert the input in the free data space
    return 1; //returns 1 for success
}
Reply


Messages In This Thread
save text under several conditions - by vardanega - 22.01.2011, 11:43
Re: save text under several conditions - by hanzen - 22.01.2011, 11:45
Re : save text under several conditions - by vardanega - 22.01.2011, 11:47
AW: save text under several conditions - by Nero_3D - 22.01.2011, 12:22
Re : save text under several conditions - by vardanega - 22.01.2011, 12:46
Re : save text under several conditions - by vardanega - 22.01.2011, 12:57
AW: Re : save text under several conditions - by Nero_3D - 22.01.2011, 17:24

Forum Jump:


Users browsing this thread: 1 Guest(s)