Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* CABEÇALHO
- Arquivo: LISTA 06 - Exercicio 3.c
- Objetivo: Construa uma estrutura agenda para armazenar alguns dados.
- Autor(a): Ramon Borges
- */
- #include <stdio.h>
- #define MAX 50
- #define NUMPHONE 10
- struct contato
- {
- char nomeEmpresa[30], pessoaRespons[40], telefones[NUMPHONE][12];
- int contadorPHONE;
- };
- int main()
- {
- struct contato agenda[MAX];
- int i, j, contCONTATOS;
- for(i = 0; i < MAX; i++)
- {
- agenda[i].contadorPHONE = 0;
- printf("\nInforme o nome da empresa (digite ENTER p/ sair): ");
- gets(agenda[i].nomeEmpresa);
- if(agenda[i].nomeEmpresa[1] == '\0')
- break;
- printf("\nInforme o nome do responsavel: ");
- gets(agenda[i].pessoaRespons);
- for(j = 0; j < NUMPHONE; j++)
- {
- printf("\nInforme o %d telefone (digite ENTER p/ finalizar) \nEX: DDD98761234\n=>",j+1);
- gets(agenda[i].telefones[j]);
- if(agenda[i].telefones[j][1] == '\0')
- break;
- agenda[i].contadorPHONE++; // conta o numero total de telefones por contato.
- }
- }
- contCONTATOS = i; // conta o numero de contatos cadastrados.
- //Exibir no console
- printf("******************* DADOS *********************************\n");
- for(i = 0; i < contCONTATOS; i++)
- {
- printf("%s\n", agenda[i].nomeEmpresa);
- printf("%s\n", agenda[i].pessoaRespons);
- for(j = 0; j < agenda[i].contadorPHONE; j++)
- printf("%s\n", agenda[i].telefones[j]);
- printf("-------------------------------------\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment