check for correct ammount of points in the file

This commit is contained in:
Chris Cromer 2018-12-08 17:27:22 -03:00
parent 16cbf3ad88
commit 7b0092126d

View File

@ -239,6 +239,10 @@ int read_file(char *filename, point_t **points, unsigned int *n) {
break; break;
} }
i++; i++;
if (j > *n) {
fprintf(stderr, "Error: Hay demasiado puntos!\n");
return 8;
}
token = strtok(NULL, " "); token = strtok(NULL, " ");
} }
} }
@ -246,6 +250,10 @@ int read_file(char *filename, point_t **points, unsigned int *n) {
buffer = NULL; buffer = NULL;
size = 0; size = 0;
} }
if (j < *n) {
fprintf(stderr, "Error: No hay suficiente puntos!\n");
return 9;
}
return 0; return 0;
} }