Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ncurses.h>
- #include <string.h>
- #define max 10
- struct registro
- {
- char nombre[15]; char cedula[8]; char direccion[20]; int edad;
- };
- void leer(registro vector[], int lim)
- {
- char pre;
- int i;
- for (i=0;i<=lim;i++)
- {
- printf("\nindique cual es su nombre\n");
- scanf("%s",vector[i].nombre);
- printf("indique su numero de cedula\n");
- scanf("%s",vector[i].cedula);
- printf("diga cual es su direccion\n");
- scanf("%s",vector[i].direccion);
- printf("indique su edad\n");
- scanf("%d",&vector[i].edad);
- printf("\n¿Desea ingresar otra persona?\n");
- pre=getch();
- if (pre!='s')
- i=lim;
- }
- }
- void buscar(registro vector[], int lim)
- {
- int i,valor;
- char buscar[15];
- printf("\nDiga cual nombre desea buscar\n");
- scanf("%s",buscar);
- for (i=0;i<=lim;i++)
- {
- valor = strcmp( buscar, vector[i].nombre );
- if (valor==0)
- {
- printf("\nEl nombre se encuentra registrado en la posicion %d\n",i);
- i=lim;
- }
- }
- if (valor!=0)
- printf("\nEl nombre %s no esta registrado\n",buscar);
- getch();
- }
- int main()
- {
- registro datos[max];
- leer(datos,max);
- buscar(datos,max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment