• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Getting the size of an array
#1
I have a multi-dimensional array, and I want to get the size of each line.

Code:
new BusRoutes[][] = {
? ? {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
? ? {0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10}
};


Code:
new const MaxStops[] = sizeof(BusRoutes[]);

Code:
format(sStops, sizeof(sStops), "Stops: 0/%d", MaxStops[vRoute]);

If vRoute = 0, it works fine, but if it equals 1, the function crashes and it doesn't continue running the rest of the function. Something is wrong with MaxStops[vRoute] if vRoute equals anything other than 0.

What am I doing wrong?
  Reply
#2
For now I've had to do this...



Code:
new MaxStops[] = {11, 11};



It works but not really how I wanted to do it.
  Reply
#3
Code:
new const MaxStops[sizeof(BusRoutes)] = {11, 11};
  Reply
#4
(2021-04-16, 08:03 PM)Radical Wrote:
Code:
new const MaxStops[sizeof(BusRoutes)] = {11, 11};



That's kinda useless really.
  Reply


Forum Jump: