Bucle Array Problem.

 

first of all, sorry for my bad English.

I have problems storing data in a user-defined array using a loop ... I can store data in each position of the array by itself, but I can not store data in an array using a loop.

someone can show me how to do it with an example?

thanks.

 

There are no mind readers here. We have no idea what your problem is without seeing your code. Your problem could be your declaration, your loop, or your assignment.

 
my question is basic, do not need to see my code base.

int MyArray [10];
MyArray[5] = 2;

what I have written is the declaration of an array and the assignment of value in the cell 5.

My question is;

How I can use a loop to assign values ​​to the 10 cells in this array? ...

I know the sintanxis of a loop, but I can not write the body of the loop because i do not know how assign values ​​to the array using a for loop.

thanks.
 
KazeKiriNo:

My question is;

How I can use a loop to assign values ​​to the 10 cells in this array? ...

I know the sintanxis of a loop, but I can not write the body of the loop because i do not know how assign values ​​to the array using a for loop.

For example:

int start() {
   int MyArray[10];

   for (int index = 0; index < ArraySize(MyArray); index++)
      MyArray[index] = index * 100;

   Print ("The fifth cell of MyArray = ", MyArray[4]);

   return (0);
}

Remember that arrays are zero-based.

 
Thirteen:

For example:

Remember that arrays are zero-based.


Thanks you thirteen, is exactly what I wanted.
Reason: