: Hi,
: I want to read records from a file and store them into an array,
: but the problem is I don't know how many records I'll read,
: so I don't know how to declare the array.
: I tried this:
: struct sRec {
: char sStdNo[9];
: int sMarks[3];
: float sFinal;
: };
: struct sRec studentRec[];
: but there is a warning (no warning in Visual C or Turbo C, but a warning in
: UNIX C).
C doesn't have arbitrary sized arrays. Either use a linked list,
or a dynamically sized array with storage generated as needed with
realloc(); which you use depends on what you're planning to do with
the data, and how much the data varies over the life of the program.
Will