I have the following .txt file:
{{1,2,3,0}, {1,1,1,2}, {0,−1,3,9}}
This is a 3x4 matrix. I'm using strtok
to extract the numbers and saving on a float
matrix. The problem is, when p gets -1, it's being converted to zero when saved on matrix. How could I fix it?
p = strtok(&matrix[0u], " {},");
for (i = 0; i < m + 1; i++){
for (j = 0; j < n + 1; j++) {
aux[i][j] = atoi(p);
if (p)
p = strtok(NULL, " {},");
}
}
Is there a better way to extract the numbers, one at a time? How?