Reaction Help
#7

I confused.
I made one, but I haven't learn about the stock, so I don't know how it works.
pawn Код:
stock randomletters(string[], maxlen = sizeof(string))
{
    new i;
    while(i < maxlen)
    {
        if(random(2))
            string[i] = random(26) + 65; //upper
        else
            string[i] = random(26) + 97; //lower
        i++;
    }
    string[i] = EOS;
    return string;
}
This is compiles fine, but it will not correct I guess, because as you mentioned before maxlen = sizeof(string) must be -1 . Is the EOS is correct?
Also,
pawn Код:
stock randomletters(string[], maxlen = sizeof(string))
{
    new i;
    while(i < maxlen = sizeof(string) -1)
    {
        if(random(2))
            string[i] = random(26) + 65; //upper
        else
            string[i] = random(26) + 97; //lower
        i++;
    }
    string[i] = EOS;
    return string;
}
I made the i < maxlen = sizeof(string) -1, but I got 3 errors and 3 warnings at line
pawn Код:
while(i < maxlen = sizeof(string) -1)
Warnings:
warning 211: possibly unintended assignment
warning 224: indeterminate array size in "sizeof" expression (symbol "")
warning 215: expression has no effect

Errors:
error 022: must be lvalue (non-constant)
error 001: expected token: ")", but found "sizeof"
error 001: expected token: ";", but found ")"

But as I saw, it must be while(i < maxlen)
Reply


Messages In This Thread
Reaction Help - by Kostas' - 07.11.2011, 17:55
Re: Reaction Help - by RyDeR` - 07.11.2011, 17:57
Re: Reaction Help - by Kostas' - 07.11.2011, 19:04
Re: Reaction Help - by RyDeR` - 07.11.2011, 19:06
Re: Reaction Help - by Kostas' - 07.11.2011, 20:15
Re: Reaction Help - by Jefff - 07.11.2011, 23:14
Re: Reaction Help - by Kostas' - 08.11.2011, 12:48

Forum Jump:


Users browsing this thread: 1 Guest(s)