checks for input, restructured project files
This commit is contained in:
parent
6317cbfaec
commit
ca827dcc71
19 changed files with 46 additions and 6 deletions
2
Makefile
Normal file
2
Makefile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
voronoi1 : voronoi.c
|
||||||
|
gcc -Wall -Wextra -pedantic -g -o voronoi1 voronoi.c
|
42
voronoi.c
Normal file
42
voronoi.c
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "voronoi.h"
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
FILE *dataset = NULL, *polygonData = NULL, *output = NULL;
|
||||||
|
checkInputArgs(argc, argv, &dataset, &polygonData, &output);
|
||||||
|
|
||||||
|
fclose(dataset);
|
||||||
|
fclose(polygonData);
|
||||||
|
fclose(output);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkInputArgs(int argc, char **argv, FILE **datasetFile, \
|
||||||
|
FILE **polygonFile, FILE **outputFile) {
|
||||||
|
char *openFileError = "Error: Unable to open file %s\n";
|
||||||
|
char *numFilesError = "Error: Incorrect number of inputs (3 required).\n";
|
||||||
|
|
||||||
|
if (argc != 4) {
|
||||||
|
fputs(numFilesError, stderr);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
*datasetFile = fopen(argv[1], "r");
|
||||||
|
if (*datasetFile == NULL) {
|
||||||
|
fprintf(stderr, openFileError, argv[1]);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
*polygonFile = fopen(argv[2], "r");
|
||||||
|
if (*polygonFile == NULL) {
|
||||||
|
fprintf(stderr, openFileError, argv[2]);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
*outputFile = fopen(argv[3], "w");
|
||||||
|
if (*outputFile == NULL) {
|
||||||
|
fprintf(stderr, openFileError, argv[3]);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
2
voronoi.h
Normal file
2
voronoi.h
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
void checkInputArgs(int argc, char **argv, FILE **datasetFile, \
|
||||||
|
FILE **polygonFile, FILE **outputFile);
|
BIN
voronoi1
BIN
voronoi1
Binary file not shown.
|
@ -1,6 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
puts("Hello World!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in a new issue