Untitled
unknown
c_cpp
2 years ago
593 B
6
Indexable
/* read rows from file, create struct Data and store it in the array */ int initObjectsArray(Point *points_array, int n) { int i, res; /* open file */ FILE *file = fopen("input.txt", "r"); if (file == NULL) { printf("Error opening the file.\n"); MPI_Abort(MPI_COMM_WORLD, __LINE__); } for (i = 0; i < n; i++) { Point point; res = fscanf(file, "%d %f %f %f %f", &point.id, &point.x1, &point.x2, &point.a, &point.b); if (res != 5) { return 1; } else { points_array[i] = point; } } /* close file */ fclose(file); return 0; }
Editor is loading...