I tried to scan some coordinates [X, Y, Z] from a file, but always returned as segmentation fault. So, I've some questions to make:
- I don't know how many points are in the file, but if I leave the struct arrays empty, there will be an error. There is a way to do this without defining a max number? 
- Are my use of pointers ok? I'm not very talented with them. 
I think that what is causing the segmentation fault is the fscanf, but I can't fix it
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define MAX 20000
FILE *f1;
struct points{
  int       n;
  float x[MAX];
  float y[MAX];
  float z[MAX];
};
int main (){
  int i;
  struct points cart1[MAX];
  f1 = fopen("point_cloud1.txt", "r");
  if (f1 == NULL){
    printf("Error Reading File\n");
    exit (0);
  }
  for(i = 0; !feof(f1); i++){
    fscanf(f1, "%f%f%f", &cart1[i].x[i], &cart1[i].y[i], &cart1[i].z[i]);
  }
  (*cart1).n = i+1;
  printf("\nNumber: %d coord1: %f, %f, %f\n", (*cart1).n, (*cart1).x[0], (*cart1).y[0], (*cart1).z[0]);
  fclose(f1);
return 0;
}
The beginning of the file is like this:
2.84838 -1.21024 -0.829256
7.09443 -3.01579 0.134558
3.31221 -1.40868 -0.830969
7.09813 -3.01883 0.404243
4.05924 -1.72723 -0.857496
 
     
     
    