I need to initialize a global array whose length is to be determined by a command line parameter. Any help would be appreciated.
I need to initialize a global array whose length is to be determined by a command line parameter. Any help would be appreciated.
There ain't no such a thing as "a global array whose length is to be determined". (There are variable-length arrays in C99, but they must have block scope.) If you actually have to have a global array (10-to-1 says you don't, but it just may be possible that you do), you'll have to declare a pointer to whatever-type-is-in-your-array, and then allocate the memory later, once you've processed the command-line parameter.
If I assume there is already an array, then
Something like this??
-------
Read length
convert to int
for 0 to length
array[i] = 0
Last edited by mcha; 02-03-2008 at 06:51 PM.