int array not working

To add comments, please log in or register
Cristi Margaritescu
35
Cristi Margaritescu  

int c[];

c[1]=1;

print(c[1]);

it prints c[1] as being zero.

Alain Verleyen
36154
Alain Verleyen  

Don't double post please ! I removed your other post.

You need to use ArrayResize() when you declare a dynamic array.

Cristi Margaritescu
35
Cristi Margaritescu  
Alain Verleyen:

Don't double post please ! I removed your other post.

You need to use ArrayResize() when you declare a dynamic array.

sorry. i made it work with declaring a number in [] ;
Carl Schreiber
Moderator
7136
Carl Schreiber  
Cristi Margaritescu:

int c[];

c[1]=1;

print(c[1]);

it prints c[1] as being zero.

  1. Use Alt-S for code please!
  2. int c[] creates an array with size 0 - you can't assign any value (so far)
  3. int c[1] creates an empty array with size 1!
  4. In the editor press F1 and search for ArrayResize() - start reading!
Cristi Margaritescu
35
Cristi Margaritescu  
thanks for the quick replies.
To add comments, please log in or register