Created
January 28, 2016 11:37
-
-
Save jmramirezpro/0feec18605d7a1007a14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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