Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicomedes77 committed Apr 10, 2021
2 parents ab647d8 + c29f6b8 commit 7739adb
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 15 deletions.
14 changes: 14 additions & 0 deletions inc/alumnos.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ char cadena[100];
/*=====[Prototypes (declarations) of public functions]=======================*/

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

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
85 changes: 77 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 @@ -51,9 +52,77 @@ bool NicolasVargas(char * cadena, size_t espacio) {
.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]================================*/
60 changes: 53 additions & 7 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,58 @@

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



int main(int argc, char *argv[]) {
if (NicolasVargas(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 7739adb

Please sign in to comment.