Advertisement
Marcos_Carvalho

Aula LCS struct

May 27th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. struct cadastro{
  5. char nome[60];
  6. int dia ,mes , ano ;
  7. char pai[60],mae[60];
  8. char sexo;
  9. char rua [60];
  10.  
  11. char bairro[60], cidade[60];
  12. int ddd;
  13. int fone;
  14.  
  15. }cad1,cad2;//variaveis globais.
  16. int main(){
  17. int opcao;
  18. do{
  19. printf(" MENU \n 1 CADASTRAR \n 2 VISUALIZAR CADASTRO \n 3 SAIR\n\n");
  20.  
  21. scanf("%d",&opcao);
  22. system("cls");
  23.  
  24.  
  25.  
  26. switch(opcao){
  27. case 1:
  28. printf("nome da crianca: ");
  29. setbuf(stdin,NULL);
  30. gets(cad1.nome);
  31. printf("NASCIMENTO: dia mes e ano: ");
  32. scanf("%d %d %d",&cad1.dia,&cad1.mes, &cad1.ano);
  33. setbuf(stdin,NULL);
  34. printf("nome do pai: ");
  35. gets(cad1.pai);
  36. setbuf(stdin,NULL);
  37. printf("nome da mae: ");
  38. gets(cad1.mae);
  39. printf("sexo do bebe: ");
  40. scanf("%c",&cad1.sexo);
  41. setbuf(stdin,NULL);
  42. printf("nome rua: ");
  43.  
  44. gets(cad1.rua);
  45. setbuf(stdin,NULL);
  46. printf("nome bairro: ");
  47. gets(cad1.bairro);
  48. setbuf(stdin,NULL);
  49. printf("nome cidade: ");
  50. gets(cad1.cidade);
  51. printf("DDD: ");
  52. scanf("%d",&cad1.ddd);
  53. printf("telefone: ");
  54. scanf("%d",&cad1.fone);
  55. break;
  56. system("cls");
  57.  
  58. case 2:
  59. printf("\n nome da crianca: %s", cad1.nome);
  60. printf("\n dta de nascimento %d / %d / %d",cad1.dia, cad1.mes, cad1.ano);
  61. printf("\n nome do pai %s \n nome da mae %s \n",cad1.pai, cad1.mae);
  62. printf("sexo do bebe: %c \n",cad1.sexo);
  63. printf("nome da rua: %s \n",cad1.rua);
  64. printf("nome do bairro: %s \n",cad1.bairro);
  65. printf("nome da cidade: %s \n",cad1.cidade);
  66. printf("telefone %d %d",cad1.ddd, cad1.fone);
  67. break;
  68. }
  69.  
  70.  
  71. } while (opcao != 3);
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement