| | |
array declaration explanation needed
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
no you can't.
It just means the number is undefined. You're declaring an array of 3 arrays. The number of elements of each of those 3 arrays is unknown at this time but will have to be fixed at some point.
It doesn't even have to be the same number of elements for each I think (not 100% certain here, could be I'm confused with Java where such is the case).
Of course unlimited numbers are impossible as the index must be an integer type and therefore fit into a 32 bit (or 64 bit depending on compiler/platform) word. It's also limited by the amount of installed memory in the client machine.
It just means the number is undefined. You're declaring an array of 3 arrays. The number of elements of each of those 3 arrays is unknown at this time but will have to be fixed at some point.
It doesn't even have to be the same number of elements for each I think (not 100% certain here, could be I'm confused with Java where such is the case).
Of course unlimited numbers are impossible as the index must be an integer type and therefore fit into a 32 bit (or 64 bit depending on compiler/platform) word. It's also limited by the amount of installed memory in the client machine.
You didn't mention where this is, I can think of two valid places:
In this case, the declaration fixes the size based on how many initializers you give it. So it IS a fixed number, but you didn't have to tell the declaration syntax how many.
The other case is like this:
In this case you have to somehow know at run time how big the array is; for example as a parameter to the function.
In this second case, you could pass many different arrays with different sizes to this routine (as long as they were triplets of GLfloats).
C Syntax (Toggle Plain Text)
GLfloat colours[][3] = { { 1.0, 1.1, 1.2 }, { 1.3, 1.4, 1.5 }, <and on and on> };
The other case is like this:
C Syntax (Toggle Plain Text)
void PrintColorArray( GLfloat colours[][3] ) // heck in the USA we spell differently { for (int i = 0; i < ?????; i++) // what do we fill in here? printf( "Color %d is %f,%f%f\n", i, colours[i][0], colours[i][1], colours[i][2] ); }
In this second case, you could pass many different arrays with different sizes to this routine (as long as they were triplets of GLfloats).
![]() |
Similar Threads
- array declaration problem (C++)
- Array Question (C++)
- finiding min in array till satisfies condition explained in prbm stmnt (C++)
- Array declaration problem (C++)
Other Threads in the C Forum
- Previous Thread: Solution Of Simultaneous Equation
- Next Thread: Weird segfault involving popen
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile csyntax directory drawing dynamic executable fflush file fork frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop initialization interest km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling scripting segmentationfault send shape socketprograming spoonfeeding stack standard string strings structures student suggestions systemcall test testautomation unix user variable voidmain() wab win32api windows.h






