Struct Arreglo de estruct. nombre edad, SIMPLE

arreglos de estructuras.html
#include <stdio.h>

struct persona{
	char nombre[20];
	int edad;
}personas[5];

int main(){
	
	int i;
	for(i=0; i<5; i++){
		fflush(stdin);
		
		printf("Escribe tu nombre: \n");
		gets(personas[i].nombre);
		printf("Escribe tu edad: \n");
		scanf("%d",&personas[i].edad);
		printf("\n");
	}
	
	for(i=0; i<5; i++){
		printf("Su nombre es: %s \n",personas[i].nombre);
		printf("Su edad es: %d \n",personas[i].edad);
	}printf("\n\n");
	
	
	system("pause");
	return 0;
}


No hay comentarios:

Publicar un comentario