Hello,
I need to make a program that can read a file and store the file's values in an array.
My first step was to find the size of the file using FSEEK in conjunction with the ftell function.
Now my question is in regards to sizing the array which will hold the values of the file.
Will the size of the array needed be exactly the size of the value returned by the ftell function? I'm using fgets to retrieve the data, so would I have to increase the size in order to store a "NULL" value?
Here is a sample of the code:
Code:
...
fseek(in,0,SEEK_END);
size=ftell(in);
array=(char*)malloc(size*sizeof(char));
while ((fgets(data,size,in)) != NULL)
{
}
...
Thanks!