Skip to content

Instantly share code, notes, and snippets.

@jmramirezpro
Created January 28, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmramirezpro/0feec18605d7a1007a14 to your computer and use it in GitHub Desktop.
Save jmramirezpro/0feec18605d7a1007a14 to your computer and use it in GitHub Desktop.
/*
* Estructuras.c
* Solución a los ejercicios del podcast Codigo Fuente - Programa 19
* Programa que define y usa estrucuras en Lenguaje C
* Creado el 27 de ene. de 2016
* Author: jmramirez
*/
#include <stdio.h>
#include <string.h> /* Evitamos un warning a la hora de compilar */
/* Definición de la estructura */
struct Fecha
{
int dia;
char mes[16];
int anyo;
};
int main(void)
{
/* Variables de tipo Fecha */
struct Fecha hoy;
struct Fecha ayer;
hoy.dia = 27;
strcpy(hoy.mes, "Enero");
hoy.anyo = 2016;
ayer.dia = 26;
strcpy(ayer.mes, "Enero");
ayer.anyo = 2016;
printf("Hoy es %d de %s de %d\n", hoy.dia, hoy.mes, hoy.anyo);
printf("Ayer era %d de %s de %d\n", ayer.dia, ayer.mes, ayer.anyo);
/* Copiamos la escrutura */
ayer = hoy;
printf("Hoy es %d de %s de %d\n", hoy.dia, hoy.mes, hoy.anyo);
printf("Ayer era %d de %s de %d\n", ayer.dia, ayer.mes, ayer.anyo);
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment