9511_project01

project 1 for algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
commit 51eb5669df39e452a73385b34ea376a9d65d7c71
parent 114532b62c051015038274f1e2fa2571391be00a
Author: klewer-martin <martin.cachari@gmail.com>
Date:   Thu, 11 Feb 2021 15:38:36 -0300

Update: Removed a segmentation fault error when running application
with arguments in wrong order;

Diffstat:
MMakefile | 10+++++++++-
Marguments.c | 4++++
Mmain.c | 1+
Mperrors.h | 2+-
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -26,8 +26,13 @@ print_file.o: print_file.h main.h
 
 
 clean:
-    rm -f *.o 
+    rm -f *.o
 
+clear:
+    rm -f analisis_covid
+
+
+# Para probar la invocacion de el programa;
 run: 
     ./analisis_covid -in input.csv -out output.txt
 
@@ -51,3 +56,6 @@ run7:
 
 run8: 
     ./analisis_covid -in input.csv 
+
+run9:
+    ./analisis_covid output.txt -out input.csv -in
diff --git a/arguments.c b/arguments.c
@@ -9,6 +9,10 @@ status_t validate_arguments(int argc, char * argv[], char * src, char * dest)
     else if(argv == NULL)
         return ERROR_NULL_POINTER;
 
+    if((strcmp(argv[1], INPUT_ARGUMENT)) && (strcmp(argv[3], OUTPUT_ARGUMENT)))
+        if((strcmp(argv[1], OUTPUT_ARGUMENT)) && (strcmp(argv[3], INPUT_ARGUMENT)))
+            return ERROR_INVOCATING_PROGRAM;
+
     status_t inputFile, outputFile;
     inputFile = outputFile = IO_FILE_NOT_FOUND;
 
diff --git a/main.c b/main.c
@@ -26,6 +26,7 @@
 
 int main(int argc, char * argv[])
 {
+    puts(argv[1]);
     status_t st;
 
 //    Las siguientes variables son para guardar los nombres de los archivos de 
diff --git a/perrors.h b/perrors.h
@@ -9,7 +9,7 @@
 
 #define MSG_ERROR_INVOCATING_PROGRAM    "\nERROR_INVOCATING_PROGRAM (2)\n"\
                                         "Uso:\t$ ./main -in <input file> -out <outputfile>\n"\
-                                        "\t$     ./main -out <output file -in <input file>\n"\
+                                        "\t    $ ./main -out <output file -in <input file>\n\n"\
                                         "Lee el archivo README.md para saber mas"
 
 #define MSG_IO_FILE_NOT_FOUND     "\nIO_FILE_NOT_FOUND (1)\n"\