How do I read each line of a file opened in my C program to an integer array.
I cannot use fgets and sscanf as the input is not known beforehand. The length of each row and the number of columns can vary.
Tried fscanf, fgetc, and others, but they seem to run into problems while detecting the newline. And I ended up reading the entire file together, instead of into different arrays.
e.g., the file contains:
1 2 3 4 5
1 2 3
2 3 4
This should be stored in arr1[] = {1,2,3,4,5} , arr2[] = {1,2,3} , arr3[] = {2,3,4}