I am currently programming a c program which gets text files as input. in every line I am getting a known ahead n float numbers, separated with comma. example line:
0.92,0.21,0.98,1
0.23,0.37,0.29,-1
0.22,0.35,0.63,1
0.14,0.89,0.78,-1
0.26,0.42,0.67,1
0.01,0.77,0.92,-1
0.67,0.12,0.59,-1
I need to put the numbers in an array. here is part of my code:
strcpy(tmp_line,strtok (line,","));
for(int j = 0;j < n + 1; j++)
{
vec.arr[j] = atof(tmp_line);
strcpy(tmp_line,strtok (NULL, ","));
}
I don't know why, when I use clion, in the end of the loop the program just stops running. when I use codeblocks, it give this message
PROCCES RETURNED (0Xc0000005)
which means we are using memory that we cannot access.
help? anybody?
a few notes:
vec
is a Vector struct. a Vector struct contains a 75 long array and a (int) tag. we use the first n cells of the array and put the tag (+ or - 1) in the n+1 cell (and the tag part).
tmp_line
is a char array contains the current line.