If you are trying to mimic the behavior of PHP's
file() (without the optional arguments), you need to create an array of cstrings, with each cstring being a copy of a file-line.
For that, fgets() would be a better option for reading the file into the array of cstrings. If you are not familiar with pointers and dynamic memory management, the task may not be trivial, but if you are it's not a big deal (assuming the max length of any line in the file is known before hand).
A struct describing a line like the following:
Code:
typedef struct Line {
char *string;
} Line;
may prove handy if you don't feel like dealing with double pointers.
Since mem for 2000000 cstrings may be quite big for the stack, you can allocate dynamically in the heap an array of 2000000 Line structs...
Code:
Line *lines = calloc( 2000000, sizeof(*lines) );
Then you can fgets() each line from the file into a temp cstring within a loop, duplicating it into lines[i].string as you go.