Question about array 
Author Message
 Question about array

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).

Please give me some suggestion

Thanks,



Thu, 04 Oct 2001 03:00:00 GMT  
 Question about array
: 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



Thu, 04 Oct 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Question: extern *array and array[]

2. Question about array initializers, const

3. question on arrays

4. Question about arrays

5. a question on array!

6. Stupid question about array boundries

7. question about array of pointers to chars

8. question about array?

9. Newbie question about arrays

10. Newbie question: Making arrays bigger

11. A question about arrays,pointers and structures

12. Question about arrays and pointers

 

 
Powered by phpBB® Forum Software