I have two files, 2dim.dat and 3dim.dat, which respectively contain the following in their 3rd line:
2 12
and
1 0 0
Their 3rd line is the only one relevant to our interest. A function is written that computes for us how many numbers will there be in that line, and the program then constructs an array of unsigned ints with that many dimensions. I know I can assign the values 2 and 12 from 2dim.dat into the dimensions of that array in a C program by doing
if(fscanf("%hu %hu", &number[0], &number[1]) == 2){}
It is similarly done for 3dim.dat.
What if I receive a file that contains more values in a line, like 4, 20 or even 270? I don't know how to tell fscanf to have 270 repeats of %hu separated with spaces in its first argument and then add all dimensions of our array.