First off. This is my first c project (and one of the first programming projects in any language), so if my syntax looks strange or I do some strange stuff I appolgize.
I have a program where three input files are used. Each file contains a few numbers, some are integers and some are floats. I've managed to check if the files exist, but not the other stuff. If any of these demands are not met the program should end and display an error message accordingly. I've seen questions around asking one one of these things, but not combined. The answers I have seen also demands quit a bit of space. I was hoping to get this done without on as few lines as possible. Help is much appreciated.
One of the scripts I've been working on can be seen below. It's gives an error message if the input file is not there, but I have removed my attempts at checking for int vs. float and if they are within range.
-------------------------------------------------------------------------------------------
Code:
void visualreader(int *x_range, int *y_range, int *z_range, int *x_cells, int *y_cells, int *z_cells, int *time){
//Scans the input file containing parameters for the visualizing the velocity vector field
FILE *fp = fopen("visual_input.dat", "r");
if(fp){
fscanf(fp, "%d %d %d\n", x_range, y_range, z_range);
fscanf(fp, "%d %d %d\n",x_cells, y_cells, z_cells);
fscanf(fp, "%d\n",time);
fclose( fp );}
else{
perror("error opening the file" );
}
}