Skip to content

Instantly share code, notes, and snippets.

@HiagoSouz
Created July 12, 2017 15:33
Show Gist options
  • Save HiagoSouz/105b349e47211aaa2a9e110809065529 to your computer and use it in GitHub Desktop.
Save HiagoSouz/105b349e47211aaa2a9e110809065529 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#define TAM 2
typedef struct
{
char nome[20];
char tipo[15];
int integrantes,posicao;
} BANDAS;
void ler (BANDAS *banda);
void mostrar (BANDAS banda);
int main()
{
BANDAS banda[2];
int i;
for (i=0; i<TAM; i++)
{
ler (&banda[i]);
}
for (i=0; i<TAM; i++)
{
mostrar(banda[i]);
}
return 0;
}
void ler (BANDAS *banda)
{
printf("Diga qual o nome da banda: ");
gets(banda->nome);
printf("Tipo de musica: ");
gets (banda->tipo);
printf("Quantos integrantes tem a banda: ");
scanf("%d",&banda->integrantes);
printf("Posicao no seu top 5: ");
scanf("%d",&banda->posicao);
fflush(stdin);
}
void mostrar (BANDAS banda)
{
printf ("Nome: %s\n",banda.nome);
printf ("Tipo de musica: %s\n",banda.tipo);
printf ("Numero de integrantes: %d \n",banda.integrantes);
printf ("Posicao no seu TOP 5: %d \n",banda.posicao);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment