|
-
August 21st, 2003, 04:35 PM
#1
Using fscanf to read a file one line at a time
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|