[help] String size
#1

Код:
	ReactionTestString = "";
	new random_set[71] = "AaBbCcDdEeFfGgHhiJjKkLMmNnOoPpQqRrSsTtUuVvWwXxYyZz12345678901234567890";
 	for(new i=0; i<RStringLength; i++)
 	{
		ReactionTestString[i] = random_set[random(71)]; //this line
	}
what size should it be in random() ?
the string is 70 characters long, so for the null char, I used 71 characters, is that correct?

and random() should be random(70) then? .. I don't really understand ><
Reply
#2

Just use
random_set[random(sizeof(random_set))];[/pawn]
Reply
#3

Quote:
Originally Posted by //exora
Just use
random_set[random(sizeof(random_set))];[/pawn]
but sizeof() will return 71..
and than if he uses character 71 that character doesn't exist, because there are only 70 chars in that string
Reply
#4

random(n) returns numbers from 0 to n-1
Reply
#5

ooh yes like with numbers
random(20) is from 0 to 19
ok, thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)