fork download
  1. #include <stdio.h>
  2.  
  3. #include <stdlib.h>
  4.  
  5.  
  6.  
  7. typedef struct paciente
  8. {
  9. char nome[50];
  10.  
  11. float altura, peso, imc;
  12.  
  13. }paciente;
  14.  
  15.  
  16.  
  17.  
  18. paciente ler_paciente(){
  19.  
  20. paciente p;
  21.  
  22.  
  23. printf("Nome: ");
  24.  
  25. gets(p.nome);
  26.  
  27. printf("altura: ");
  28.  
  29. scanf("%f", &p.altura);
  30.  
  31. printf("peso(kg): ");
  32.  
  33. scanf("%f", &p.peso);
  34.  
  35. printf("\n");
  36.  
  37. return p;
  38.  
  39. };
  40.  
  41.  
  42.  
  43. paciente calcular(paciente* grupo, int tam){
  44.  
  45. int i=0;
  46.  
  47.  
  48.  
  49. for(;i<tam;i++);
  50.  
  51. grupo[i].imc = (grupo[i].altura * grupo[i].altura) / grupo[i].peso;
  52.  
  53. return calcular;
  54.  
  55. };
  56.  
  57.  
  58.  
  59. /*paciente mostrar_baixo_p(paciente grupo, int tam){}*/
  60.  
  61. /*paciente mostrar_p_ideal(paciente grupo, int tam){}*/
  62.  
  63. /*paciente mostrar_sobre_p(paciente grupo, int tam){}*/
  64.  
  65. /*paciente mostrar_obeso(paciente grupo, int tam){}*/
  66.  
  67.  
  68.  
  69. int main(){
  70.  
  71. int tam,i;
  72.  
  73. paciente *grupo;
  74.  
  75.  
  76. printf("Digite a quantidade de pacientes: ");
  77.  
  78. scanf("%d", &tam);
  79.  
  80.  
  81.  
  82. grupo=(paciente*)malloc(sizeof(paciente)*tam);
  83.  
  84.  
  85.  
  86. for(i=0;i<tam;i++)
  87.  
  88. {__fpurge(stdin);
  89.  
  90. grupo[i]=ler_paciente();
  91.  
  92. }
  93.  
  94.  
  95.  
  96. calcular(&grupo,tam);
  97.  
  98.  
  99.  
  100. //printf("baixo peso: \n");
  101.  
  102. //mostrar_baixo_p(grupo, tam);
  103.  
  104.  
  105. //printf("peso ideal \n");
  106.  
  107. //mostrar_p_ideal(grupo, tam);
  108.  
  109.  
  110. //printf("sobre peso \n");
  111.  
  112. //mostrar_sobre_p(grupo, tam);
  113.  
  114.  
  115. //printf("obeso \n");
  116.  
  117. //mostrar_obeso(grupo, tam);
  118. }
  119.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'ler_paciente':
prog.c:25:2: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration]
  gets(p.nome);
  ^
prog.c: In function 'calcular':
prog.c:53:9: error: incompatible types when returning type 'paciente (*)(paciente *, int) {aka struct paciente (*)(struct paciente *, int)}' but 'paciente {aka struct paciente}' was expected
  return calcular;
         ^
prog.c: In function 'main':
prog.c:88:3: warning: implicit declaration of function '__fpurge' [-Wimplicit-function-declaration]
  {__fpurge(stdin);
   ^
prog.c:96:11: warning: passing argument 1 of 'calcular' from incompatible pointer type [-Wincompatible-pointer-types]
  calcular(&grupo,tam);
           ^
prog.c:43:10: note: expected 'paciente * {aka struct paciente *}' but argument is of type 'paciente ** {aka struct paciente **}'
 paciente calcular(paciente* grupo, int tam){
          ^
prog.c: In function 'calcular':
prog.c:55:1: warning: control reaches end of non-void function [-Wreturn-type]
 };
 ^
stdout
Standard output is empty