Hi everyone,
I'm having issues while attempting to read a text file of the following structure
0 0 -7.278289
0 1 1.922087
As you see the first and second values in a line are integers, I'm not interested in those, the third value is a float which I want.
Basically I must read this file in two FOR loops, the master loop turns 10 times and for each of those iterations an "internal" loop runs another 10 times - here I extract the values and store them in an array
FILE *fp;
int i,j,k, i_in,j_in;
double p_in;
fp = fopen(fname, "r");
nn = 10;
k=0;
for (i=0;i<nn;++i){
for (j=0;j<nn;++j){
fscanf(fp,"%d %d %lg", &i_in, &j_in, &p_in);
next_line(fp);
pop[0][0][k] = p_in;
printf("i_in: %d \n j_in: %d \n Value: %lg \n", &i_in,&j_in,&p_in);
printf("i: %d\n j: %d \n k: %d \n",i,j,k);
k++;
}
}
This should load my values
-7.278289
1.922087
etc
but instead I get
i_in: -1073744740 which should be between 0 and 9
j_in: -1073744744 which should be between 0 and 9
VALUE: -1.997212 which should be the actual value, which it's not
The loops are working, the iterations are correct, it's just the extraction and storing of values that fails miserably and I fail to see the problem, the data types seem OK, I just don't get it.
Can someone please tell me what I'm doing wrong?
Cheers,