I have a file that I would like to read and that file follows a pattern, basically the file only contains integer and those integer are actually x, y, z co-ordinates of a location and followed by x, y, z co-ordinates of another location in the same line. The line does not have fixed number of coordinates. Line 1 might have co-ordinates of 15 location and line 2 might have co-ordinates of 24 location and there may be an arbitrary amount and type of whitespace (newlines, spaces, tabs) between any of the integers in the file.
> integer x_coordinates integer y_coordinates integer z_coordinates...
> integer x_coordinates integer y_coordinates integer z_coordinates...
> integer x_coordinates integer y_coordinates integer z_coordinates...
>
> integer x_coordinates integer y_coordinates integer z_coordinates...
>
>
> integer x_coordinates integer y_coordinates integer z_coordinates...
Now, I am planning to read through every line of file and avoid every empty line and store the co-ordinates into a typedef struct.
typedef struct{
int* x;
int* y;
int* z;
}Coordinates;
I want to store all the x coordinates in int* x, all y coordinates in int* y and all z coordinates in int* z.
But problem is that there can be arbitrary number and type of white spaces in between 2 numbers even between y coordinate of location 1 and z coordinate of location 1 or between z coordinate of location 5 and x coordinate of location 6.
So all in all I am not able to figure out how to use fscanf here to read through a file like this.