From 41ca0b3ffa99a1194856962c1eb12eefe25e0487 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Thu, 30 May 2024 14:20:31 +0100 Subject: [PATCH] Update emulate to check args, w/ T --- src/emulate.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/emulate.c b/src/emulate.c index e2ad1c8..3bbb3d7 100755 --- a/src/emulate.c +++ b/src/emulate.c @@ -1,5 +1,23 @@ #include +#include 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 []"); + 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; + } + } + + + }