Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jr130797 committed Apr 10, 2021
2 parents af2065b + 64e2950 commit 71a81c7
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build
/.vscode
16 changes: 15 additions & 1 deletion inc/alumnos.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,27 @@ typedef struct alumno_s {
} const * alumno_t;

/*=====[Definitions of public global variables]==============================*/

char cadena[100];
/*=====[Prototypes (declarations) of public functions]=======================*/

bool SerializarAlumno(char * cadena, size_t espacio, const alumno_t alumno);

bool IvanVargasMarza(char * cadena, size_t espacio);

bool NicolasVargas(char * cadena, size_t espacio);

bool FedericoMeghinasso(char * cadena, size_t espacio);

bool MatiasMeghinasso(char * cadena, size_t espacio);

bool MartinDuarte(char * cadena, size_t espacio);

bool AlejandroPermingeat(char * cadena, size_t espacio);

bool EstebanVolentini(char * cadena, size_t espacio);

bool LucasOrsi(char * cadena, size_t espacio);

/*=====[Prototypes (declarations) of public interrupt functions]=============*/

/*=====[C++ - end]===========================================================*/
Expand Down
95 changes: 87 additions & 8 deletions src/alumnos.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Version: 0.1.0
* Creation Date: 2019/06/21
*/

/*=====[Inclusion of own header]=============================================*/

#include "alumnos.h"
Expand All @@ -32,16 +32,17 @@

/*=====[Implementations of interrupt functions]==============================*/

bool SerializarAlumno(char * cadena, size_t espacio, const alumno_t alumno) {
bool SerializarAlumno(char *cadena, size_t espacio, const alumno_t alumno)
{
int resultado;
const char FORMATO[] = "{"
"\"documento\":\"%s\","
"\"apellidos\":\"%s\","
"\"nombres\":\"%s\""
"}";
"\"documento\":\"%s\","
"\"apellidos\":\"%s\","
"\"nombres\":\"%s\""
"}";

resultado = snprintf(cadena, espacio, FORMATO,
alumno->documento, alumno->apellidos, alumno->nombres);
resultado = snprintf(cadena, espacio, FORMATO,
alumno->documento, alumno->apellidos, alumno->nombres);

return (resultado >= 0);
}
Expand All @@ -55,4 +56,82 @@ bool IvanVargasMarza(char * cadena, size_t espacio) {
return SerializarAlumno(cadena, espacio, &alumno);
}

bool NicolasVargas(char * cadena, size_t espacio) {
const struct alumno_s alumno = {
.apellidos = "VARGAS",
.nombres = "Nicolás",
.documento = "33.154.750",
};

return SerializarAlumno(cadena, espacio, &alumno);
}
bool FedericoMeghinasso(char * cadena, size_t espacio) {
const struct alumno_s alumno = {
.apellidos = "MEGHINASSO",
.nombres = "Federico Nicolas",
.documento = "35.229.281",
};

return SerializarAlumno(cadena, espacio, &alumno);
}

bool MatiasMeghinasso(char *cadena, size_t espacio)
{
const struct alumno_s alumno = {
.apellidos = "Matias",
.nombres = "Matias Gino",
.documento = "36.806.968",
};

return SerializarAlumno(cadena, espacio, &alumno);
}

bool MartinDuarte(char * cadena, size_t espacio) {
const struct alumno_s alumno = {
.apellidos = "DUARTE",
.nombres = "Martin Nicolás",
.documento = "38.170.436",
};

return SerializarAlumno(cadena, espacio, &alumno);
}

bool AlejandroPermingeat(char * cadena, size_t espacio) {
const struct alumno_s alumno = {
.apellidos = "PERMINGEAT",
.nombres = "Alejandro",
.documento = "00.000.000",
};

return SerializarAlumno(cadena, espacio, &alumno);
}

bool EstebanVolentini(char * cadena, size_t espacio) {
const struct alumno_s alumno = {
.apellidos = "VOLENTINI",
.nombres = "Esteban Daniel",
.documento = "23.517.968",
};

return SerializarAlumno(cadena, espacio, &alumno);
}

bool LucasOrsi(char * cadena, size_t espacio) {
const struct alumno_s alumno = {
.apellidos = "ORSI",
.nombres = "Lucas",
.documento = "38.492.146",
};
return SerializarAlumno(cadena, espacio, &alumno);
}

/*=====[Implementations of private functions]================================*/
bool JosueElias(char * cadena, size_t espacio) {
const struct alumno_s alumno = {
.apellidos = "Velardez",
.nombres = "German",
.documento = "37.165.604",
};
return SerializarAlumno(cadena, espacio, &alumno);
}
/*=====[Implementations of private functions]================================*/
58 changes: 55 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Version: 0.1.0
* Creation Date: 2019/06/21
*/

/*=====[Inclusion of own header]=============================================*/

#include "alumnos.h"
Expand Down Expand Up @@ -34,12 +34,64 @@

/*=====[Implementations of private functions]================================*/



int main(int argc, char *argv[]) {
char cadena[120];
if (IvanVargasMarza(cadena, sizeof(cadena))) {
printf("Alumno: %s\r\n", cadena);
} else {
printf("No se pudo serializar el alumno\r\n");
}

if (NicolasVargas(cadena, sizeof(cadena))) {
printf("Alumno: %s\r\n", cadena);
} else {
printf("No se pudo serializar el alumno\r\n");
}

if (AlejandroPermingeat(cadena, sizeof(cadena))) {
printf("Alumno: %s\r\n", cadena);
} else {
printf("No se pudo serializar el alumno\r\n");
}

if (EstebanVolentini(cadena, sizeof(cadena))) {
printf("Alumno: %s\r\n", cadena);
}
else {
printf("No se pudo serializar el alumno\r\n");
}

if (LucasOrsi(cadena, sizeof(cadena))) {
printf("Alumno: %s\r\n", cadena);
} else {
printf("No se pudo serializar el alumno\r\n");
}

if (MartinDuarte(cadena, sizeof(cadena))) {
printf("Alumno: %s\r\n", cadena);
} else {
printf("No se pudo serializar el alumno\r\n");
}

if (MatiasMeghinasso(cadena, sizeof(cadena)))
{
printf("Alumno: %s\r\n", cadena);
}
else
{
printf("No se pudo serializar el alumno\r\n");
}

if (FedericoMeghinasso(cadena, sizeof(cadena)))
{
printf("Alumno: %s\r\n", cadena);
}
else
{
printf("No se pudo serializar el alumno\r\n");
}


return 0;
}
}

0 comments on commit 71a81c7

Please sign in to comment.