jar00st

estructura

Jun 28th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ncurses.h>
  3. #include <string.h>
  4. #define max 10
  5. struct registro
  6. {
  7.     char nombre[15]; char cedula[8]; char direccion[20]; int edad;
  8. };
  9. void leer(registro vector[], int lim)
  10. {
  11.     char pre;
  12.     int i;
  13.     for (i=0;i<=lim;i++)
  14.     {
  15.         printf("\nindique cual es su nombre\n");
  16.         scanf("%s",vector[i].nombre);
  17.         printf("indique su numero de cedula\n");
  18.         scanf("%s",vector[i].cedula);
  19.         printf("diga cual es su direccion\n");
  20.         scanf("%s",vector[i].direccion);
  21.         printf("indique su edad\n");
  22.         scanf("%d",&vector[i].edad);
  23.         printf("\n¿Desea ingresar otra persona?\n");
  24.         pre=getch();
  25.         if (pre!='s')
  26.         i=lim;
  27.     }
  28.  
  29. }
  30. void buscar(registro vector[], int lim)
  31. {
  32.     int i,valor;
  33.     char buscar[15];
  34.    
  35.     printf("\nDiga cual nombre desea buscar\n");
  36.     scanf("%s",buscar);
  37.     for (i=0;i<=lim;i++)
  38.     {
  39.         valor = strcmp( buscar, vector[i].nombre );
  40.         if (valor==0)
  41.         {
  42.        
  43.             printf("\nEl nombre se encuentra registrado en la posicion %d\n",i);
  44.             i=lim;
  45.         }
  46.     }
  47. if (valor!=0)
  48. printf("\nEl nombre %s no esta registrado\n",buscar);
  49. getch();
  50. }
  51.        
  52. int main()
  53. {
  54.     registro datos[max];
  55.     leer(datos,max);
  56.     buscar(datos,max);
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment