#include <stdio.h>
#include <stdlib.h>
struct personas {
char nombre[50];
char ciudad [50];
int telefono;
};
int main(int argc, char** argv) {
int i = 0;
int opciones;
char buscar[50];
struct personas persona[5];
do {
puts("Introducce una opcion");
puts("0.Salir");
puts("1.Introduce los datos");
puts("2.buscar nombre en el directorio");
printf("Introduce una opcion \n");
scanf("%d", &opciones);
for (i = 0; i < 5; i++) {
switch (opciones) {
case 1:
printf("Introduce el nombre\n");
scanf("%s", &persona[i].nombre);
printf("Introduce la ciudad\n");
scanf("%s", &persona[i].ciudad);
printf("Introduce el telefono\n");
scanf("%d", &persona[i].telefono);
break;
case 2:
if (i == 0) {
printf("Introduce el nombre a buscar\n");
scanf(" %s", &buscar);
}
if (strstr(persona[i].nombre, buscar) != NULL) {
printf("El telefono de %s es %d \n", persona[i].nombre, persona[i].telefono);
}
break;
}
}
} while (opciones != 0);
return (EXIT_SUCCESS);
}