08.11.2011, 12:48
I confused.
I made one, but I haven't learn about the stock, so I don't know how it works.
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,
I made the i < maxlen = sizeof(string) -1, but I got 3 errors and 3 warnings at line
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)
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;
}
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;
}
pawn Код:
while(i < maxlen = sizeof(string) -1)
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)