Reading Data into an Array

stealthregal

New member
Joined
Apr 11, 2008
Messages
3
Programming Experience
Beginner
Ok, one quick question. I have a file of data (in two different formats) that I need to write into an array. One version is a block of numbers that has a space in between values (and what looks like hard returns at the end of each line). The other version of the file is setup like an array definition in C++. I just want to read each value into an array so I can run the numbers through a series of calculations. It looks like the Trim method might work alright on the first file, but the commas in the second one might be easier to separate out. Does anyone have any suggestions on how to best approach this?

Here is the first format (the end of each line has a small box like a return code)
26.6 27.0 27.1 27.1 27.1 27.1 26.9 26.8 26.7 26.4 26.0 25.8 25.6 25.2
25.0 24.6 24.2 24.0 23.7 23.4 23.1 22.9 22.8 22.7 22.6 22.4 22.2 22.0
19.0 18.8

This is the second format.
double temp[] = {
26.6,27.0,27.1,27.1,27.1,27.1,26.9,26.8,26.7,26.4,26.0,25.8,25.6,25.2,
25.0,24.6,24.2,24.0,23.7,23.4,23.1,22.9,22.8,22.7,22.6,22.4,22.2,22.0,
19.0,18.8,
};
 

Latest posts

Back
Top