Update emulate to check args, w/ T

This commit is contained in:
sBubshait 2024-05-30 14:20:31 +01:00
parent de40227d08
commit 41ca0b3ffa

View File

@ -1,5 +1,23 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) { int main(int argc, char **argv) {
return EXIT_SUCCESS;
// Check the arguments
if (argc == 1) {
fprintf(stderr, "Error: An object file is required. Syntax: ./emulate <file_in> [<file_out>]");
return EXIT_FAILURE;
}
FILE *out = stdout;
if (argc > 2) {
out = fopen(argv[2], "w");
if (out == NULL) {
fprintf(stderr, "Error: Could not open file %s\n", argv[2]);
return EXIT_FAILURE;
}
}
} }