Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/02/2010, 15:47
Froroth
 
Fecha de Ingreso: febrero-2010
Mensajes: 39
Antigüedad: 15 años
Puntos: 0
Respuesta: uso del typedef

Código C++:
Ver original
  1. #include <stdio.h>
  2. #define N_CLIENTES 100
  3.  
  4. typedef struct
  5. {
  6.     int identificador; 
  7.     char nom[30];  
  8.     float saldo;
  9. }datos;
  10.  
  11. int main()
  12. {
  13.     datos cliente[N_CLIENTES];
  14.     int i;
  15.  
  16.     for(i=0; i<N_CLIENTES; i++)
  17.     {
  18.         printf("Escribe idenfificador, nombre y saldo:\n");
  19.         scanf("%d%29s%f",&cliente[i].identificador, cliente[i].nom, &cliente[i].saldo);
  20.     }
  21.    
  22.     printf("\n %s","Los clientes que cobran por encima de los 100 euros son:\n");
  23.  
  24.     for (i=0; i<N_CLIENTES; i++)
  25.     {
  26.         if (cliente[i].saldo > 100)
  27.             printf("%s %.2f\n", cliente[i].nom, cliente[i].saldo);
  28.     }
  29.    
  30.     return 0;
  31. }