Topic : C-Language Documentation Author : John Kormylo Version : C.HYP 1.0 Subject : Documentation/C-Language Nodes : 233 Index Size : 6362 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : en @default : @help : Help @options : +g -i -s +x +z -t4 @width : 75 View Ref-File[ Arrays ] An array is a block of consecutive data items of the same type, referenced with a subscript in brackets [ ]. The first subscript is always 0. for(i=0; i<n; i++) array[i] = i; Arrays are defined the same as other Variables, except for the subscript range in brackets [ ] and the number of initializations. int colors[4] = {BLACK, WHITE, RED, GREEN}; One can define more than one subscript by using multiple brackets. float matrix[10][20]; When an array is initialized, one can leave the subscript range empty and the compiler will set it using the number of entries initialized. char string[] = "string"; /* sizeof(string) == 7 */ When an array is passed as a function parameter or in an extern statement, one can leave the (first) subscript range empty and pass the subscript range (if needed) separately. (Size is unknown.) extern char buffer[]; void function(int array[][10], int num); An array name without its subscript(s) is a pointer constant. Using the above examples, 'buffer' would be (const char*) and 'array' would be (const int**). 'array[i]' would be (int*) and would point to 'array[i][0]'. See also Pointers and Pointer Arrays.