Update emulate to check args, w/ T
This commit is contained in:
parent
de40227d08
commit
41ca0b3ffa
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user