Reading / input column of numbers into an array
Hello all.
I have a text file with one column of numbers (vector) e.g.:
1
2
3
4
5
6
They are separated by a return.
As I'm fairly new to C I thought I would check out my logic with you before I start writing the code. So the sequence of events to read in a vector should be:
1. Use fopen and the read option to get the file open.
2. Use scanf to make a string containing the contence of a line. It will know when to stop when it finds \n.
3. Convert the string of charaters in 2. into a number.
4. Put the number into an elemet of an array
5. Loop 2. -> 4. until EOF is returned
4. fclose
5. return number array.
If you have experience with this kind of thing, how does that sound? Any advice?
Cheers, Daniel.