Yes, you need to use a constant expression to initialize a statically allocated array. I believe that C99 (the new ANSI standard) allows you to create variable length arrays, but not C89 and since there aren't any C99 compilers yet...
So, if you want the user to specify the number, you'll have to do as palbano suggested and dynamically allocate your array.
Another option is to use a linked list (or similiar structure) to store each struct, then you don't have to know how many structs you will eventually need at all. This is preferable as it's generally not good to bother the user with these details. It's a bit more work to implement it this way, but worth it.
A "middle of the road" solution is not to ask the user the number and use malloc() and realloc() as needed by initializing the array of structs with a predetermined block size and then "growing" it as needed:
/* Untested and some stuff omitted for brevity */
#include <stddef.h>
#include <stdlib.h>
#define CHUNK_SIZE 20 /* or whatever's appropriate */
struct state {
int seed;
int who;
int lock;
};
/* ... */
struct state *foo=malloc(sizeof *foo * CHUNK_SIZE);
size_t blockSize=CHUNK_SIZE; /* Keeps track of how much
* memory we've allocated
*/
size_t fooSize=0; /* Keeps track of how many
* members are in the struct
*/
/* Enter data retrival loop */
for (;

{
/* Get user input, breaking from the loop if
* there isn't any more
*/
if (fooSize+1 > blockSize) {
/* To add another element, we need to increase
* the memory for foo
*/
struct state *tmp=realloc(foo,blockSize+CHUNK_SIZE);
if (NULL!=tmp) {
foo=tmp;
blockSize+=CHUNK_SIZE;
} else {
/* handle error and exit loop */
}
}
/* Assign input to current element of foo,
* incrementing fooSize by 1 for each
* assignment
*/
}
The big advantage that a linked list has over an array here is if you need to delete elements from your array, the operation is slow, particularly if there are a lot of elements.
HTH,
Russ
bobbitts@hotmail.com