This is straight C, not C++ or MFC. I want to know and how I can use fscanf and fputs to read a data file without determining the length. Here is what I am talking about.

My data file is in the form of

8.5
3.14
9.5
0.2
1.1

Now, it will be easier to do if I allow user to enter the length of the data, but I don't want that. I simply want user to enter the file name.

I would like to put fscanf inside a while loop and increment a counter for each line. After the end of the last line, I want to use malloc to allocate space for an array and put the value to that array. I want to know if it is possible and how I can do it.