array or pointer

Hardbody hardbody at milton.acs.washington.edu
Fri Nov 17 19:18:24 AEST 1989


Suppose I wanted to read 500 records, each of 80 bytes long, from a file,
How should I store them? Should I do

(1) char line[500][80];   since I already know the size of the file.

OR

(2) char *line[500];   But before we could use 'line,' we have to use 'malloc'
                       to allocate memory to the array of pointers.

Which case is faster as far as the time it takes to load the file in is
concerned?

Thanks plenty.



More information about the Comp.lang.c mailing list