9511_project01

project 1 for algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
commit bbb78de90a709afdf5abf82a5ce5fbbb9c0d477a
parent 855793b8f71aa689947e2a57769e3c96fcafe115
Author: klewer-martin <martin.cachari@gmail.com>
Date:   Tue,  9 Feb 2021 17:32:57 -0300

Update: removing old junk and fixing thigns that were made quickly;

Diffstat:
MMakefile | 14+++++++-------
MREADME.md | 16++++++++++++++--
Mprint_file.c | 2+-
Mread_file.c | 20++++++++++----------
Mread_file.h | 2+-
5 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,5 +1,5 @@
 CC = gcc
-CFLAGS = -std=c99 -Wall -pedantic
+CFLAGS = -std=c99 -Wall -Wextra -pedantic
 
 all: main clean
 
@@ -8,22 +8,22 @@ main: main.o arguments.o perrors.o load_country_codes.o read_file.o print_file.o
     $(CC) $(CFLAGS) main.o arguments.o perrors.o load_country_codes.o read_file.o print_file.o -o main 
 
 main.o: main.c main.h arguments.h macros.h
-    $(CC) -c main.c
+    $(CC) $(CFLAGS) -c main.c
 
 arguments.o: arguments.c arguments.h macros.h
-    $(CC) -c arguments.c
+    $(CC) $(CFLAGS) -c arguments.c
 
 perrors.o: main.c main.h
-    $(CC) -c perrors.c
+    $(CC) $(CFLAGS) -c perrors.c
 
 load_country_codes.o: load_country_codes.h main.h
-    $(CC) -c load_country_codes.c 
+    $(CC) $(CFLAGS) -c load_country_codes.c 
 
 read_file.o: read_file.h main.h
-    $(CC) -c read_file.c
+    $(CC) $(CFLAGS) -c read_file.c
 
 print_file.o: print_file.h main.h
-    $(CC) -c print_file.c
+    $(CC) $(CFLAGS) -c print_file.c
 
 
 clean:
diff --git a/README.md b/README.md
@@ -7,13 +7,26 @@ runs on CLI which its function is to process data entered via
 a .csv file.
 
 What it does is receive a number for a country, date, and number of
-cases (of COVID19), and prints it on stdout with a human readable
+cases (of COVID19), and prints it on a file with a human readable
 format.
 
 Bibliography:
 
 "The C programming language" - Brian W. Kernighan & Dennis Ritchie.
 
+Linux installation:
+    Arch based distros:
+        .Install base-devel, git(not neccesary unless you want to clone
+         the repo).
+        .Clone repo from terminal or download the .zip file and unzip
+         it.
+        .Navigate to the folder and open a terminal there, run
+        'make install'.
+
+    Debian based distros:
+        .Install gcc
+
+    
 NAME
     analisis_covid - analyze RAW data and export it with a human 
     readable format.
@@ -26,7 +39,6 @@ DESCRIPTION
     Process RAW data from a .csv(comma separated values) file,
     and export it to another .csv file, if the output file doesn't
     exist then it creates one with the specified name.
-
     When you invoke analisis_covid, expects.. to be continued
 
 
diff --git a/print_file.c b/print_file.c
@@ -108,7 +108,7 @@ void fprintf_infected_monthly(FILE *dest)
 
 
     fprintf(dest, "Infectados por mes: %lu\n", infected_monthly);    
-    sprintf(str_infected_monthly, "%lu", 10);
+    sprintf(str_infected_monthly, "%u", 10);
     fprintf(dest, "-------------------%.*s\n", (length + 1), guion_medio); 
 
     free(str_infected_monthly);
diff --git a/read_file.c b/read_file.c
@@ -2,15 +2,15 @@
 #include "read_file.h"
 
 
-status_t read_file(FILE *src, u_long *country, u_long *date, u_long *infected)
+status_t read_file(FILE *src, ulong *country, ulong *date, ulong *infected)
 {
 
 //    Esta variable es para saber de que tipo de dato estamos hablando, si es un
 //    codigo de pais, una fecha o el numero de infectados;
     data_t data;
 
-    size_t line, i, j;
-    status_t st;
+    size_t i, j;
+//    status_t st;
 
     char buff1[SIZE_OF_BUFF1];
     char buff2[SIZE_OF_BUFF2];
@@ -18,7 +18,7 @@ status_t read_file(FILE *src, u_long *country, u_long *date, u_long *infected)
     clean_buffer(buff1, SIZE_OF_BUFF1);
     clean_buffer(buff2, SIZE_OF_BUFF2);
 
-    char time_s[TIME_MAX_DIGITS];
+//    char time_s[TIME_MAX_DIGITS];
 
 //    Lee de el archivo de entrada linea por linea y va guardando las 
 //    lineas en buff1 hasta que se terminen;
@@ -32,12 +32,12 @@ status_t read_file(FILE *src, u_long *country, u_long *date, u_long *infected)
         if((buff1[i] == ','))
         {
             i++;
-            switch(data) 
-            {
-                case PAIS: *(country) = atoi(buff2); break;
-                case DATE: *(date) = atol(buff2); j++; break;
-            }
-
+            if(data == PAIS) 
+                *(country) = atoi(buff2);
+            
+            else if (data == DATE) 
+                *(date) = atol(buff2);
+            
             data++;
             j = 0;
             clean_buffer(buff2, SIZE_OF_BUFF2);
diff --git a/read_file.h b/read_file.h
@@ -10,7 +10,7 @@ typedef enum {
     INFECTED
 } data_t;
 
-status_t read_file(FILE *src, u_long *country, u_long *date, u_long *infected);
+status_t read_file(FILE *src, ulong *country, ulong *date, ulong *infected);
 
 status_t fprintf_date(FILE *dest, size_t data);
 status_t fprintf_infected(FILE *dest, size_t data, char newline);