Functions with an unknown amount of arguments
#4

No, its not the same.
Your code doenst work, but my code works :P

And here i tested it:
pawn Код:
#include a_samp
main() {
    printf("%i",AddNumber_Sharpadox(1,2,3,4));  // returned 10
    printf("%i",AddNumber_sammp(1,2,3,4));      // returned 47
}

stock AddNumber_Sharpadox(...)
{
    new result;
    for(new i=0; i<numargs(); i++) result += getarg(i);
    return result;
}

stock AddNumber_sammp(...)
{
    new result = 0;

    for(new i = 0; i <= numargs(); ++i)
    {
        result += getarg(i);
    }
    return result;
}
Reply


Messages In This Thread
Functions with an unknown amount of arguments - by sammp - 29.07.2014, 22:32
Re: Functions with an unknown amount of arguments - by Sharpadox - 29.07.2014, 23:19
Re: Functions with an unknown amount of arguments - by sammp - 29.07.2014, 23:58
Re: Functions with an unknown amount of arguments - by Sharpadox - 30.07.2014, 01:17
Re: Functions with an unknown amount of arguments - by sammp - 30.07.2014, 10:37
Re: Functions with an unknown amount of arguments - by Sharpadox - 30.07.2014, 12:49

Forum Jump:


Users browsing this thread: 1 Guest(s)