Advertisement
Guest User

Untitled

a guest
May 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int opcao;
  5.     int i = 0;
  6.     struct agenda {
  7.         char nome[100];
  8.         char telefone[20];
  9.         char email[50];
  10.         char sexo;
  11.         int idade;
  12.         float peso;
  13.         float altura;
  14.     } contatos[1000];
  15.  
  16.     printf(
  17.         "****MENU AGENDA ELETRONICA****\n1: Adicionar contato\n2: Excluir "
  18.         "contato\n3: Pesquisar contato\n4: Visualizar todos os contatos\n0: "
  19.         "Sair!\n");
  20.  
  21.     scanf("%d", &opcao);
  22.     switch (opcao) {
  23.     case 1:
  24.         setbuf(stdin, NULL);
  25.         // contatos[i].nome[100]
  26.         fgets(contatos[i].nome, 100, stdin);
  27.         setbuf(stdin, NULL);
  28.         // contatos[i].telefone[20]
  29.         fgets(contatos[i].telefone, 20, stdin);
  30.         setbuf(stdin, NULL);
  31.  
  32.         // contatos[i].email[50]
  33.         fgets(contatos[i].email, 50, stdin);
  34.         setbuf(stdin, NULL);
  35.         // contatos[i].sexo
  36.  
  37.         scanf("%c", contatos[i].sexo);
  38.         setbuf(stdin, NULL);
  39.         // contatos[i].idade
  40.         scanf("%c", contatos[i].idade);
  41.         setbuf(stdin, NULL);
  42.         // contatos[i].peso
  43.         scanf("%c", contatos[i].peso);
  44.         setbuf(stdin, NULL);
  45.         // contatos[i].altura
  46.         scanf("%c", contatos[i].altura);
  47.  
  48.         i++;
  49.         break;
  50.     }
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement