numerical data into array

Mar 19, 2015 at 1:53pm
Hi, I know this question has been around since forever but because of this I have no clue of which is the correct way of doing the following:
I have a file with numerical data store in columns

1
2
3
4
5
6
7
8
  File
  time voltage current
  1     1.1     0.1
  2     1.2     0.12
  3     1.1     0.13
  4     1.4     0.14
  5     1.2     0.11
  6     1.1     0.12


I want to store this data to some kind of variable: maybe an array[][][] or an array of struct{double a;double b; double c;}. My goal is to have an array of numbers for each column.

Thanks
Mar 19, 2015 at 2:01pm
Im not exactly sure on how to solve this, but What Im sure of is that you do not want to use a
array[][][]
Mar 19, 2015 at 2:11pm
at least 1 array per variable: time[i], voltage[i], current[i].
Mar 19, 2015 at 2:15pm
Actually... A two-dimensional array would work great. Something like

float arr[6][2]

for(int i = 0; i < 6; i++)
{
for(int k = 0; k < 2; k++)
{
//do the shit here
}
}

Edit: Only "downside" I see to this is that 1,2,3,4,5,6 are integers, and its an float array, but I think thats fine.
Last edited on Mar 19, 2015 at 2:16pm
Topic archived. No new replies allowed.