Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include <stdlib.h>
- #define p printf
- #define s scanf
- #include <string.h>
- typedef struct contacto{
- char equipo[80];
- char nombre[80];
- char telefono[80];
- };
- typedef struct contacto contacto_t;
- int numero; /** el numero del menu de opciones*/
- int numerodeamigos; /** el numero de amigos que quiero agregar a la agenda */
- int contadorAGREGAR; /** el contador del for agregar*/
- int contadorELIMINAR; /** el contador del for de eliminar */
- int x,y;
- contacto_t* contacto1 = malloc(sizeof(contacto_t));
- int main(void)
- {
- /*******************************************/
- /*******************************************/
- /************ MENU DE OPCIONES **************/
- /*******************************************/
- /*******************************************/
- do
- {
- system("COLOR 2");
- p("\n\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES\n\n\n\n");
- p("\t1.AGREGAR CONTACTO\n");
- p("\n\t2.MOSTRAR TODOS LOS CONTACTOS DE TU AGENDA \n\n");
- p("\t3.MOSTRAR LOS CONTACTOS CARAQUISTA\n");
- p("\t4.MOSTRAR LOS CONTACTOS MAGALLANEROS\n");
- p("\t5.BUSCAR CONTACTO\n");
- p("\t6.ELIMINAR CONTACTO\n");
- scanf("%i",&numero);
- switch(numero)
- {
- /*******************************************/
- /*******************************************/
- /************ AGREGA LOS CONTACTOS **************/
- /*******************************************/
- /*******************************************/
- case 1:{
- system("cls");
- printf("ingrese el nombre: ");
- fflush(stdin);
- gets(contacto1->nombre[10]);
- printf("Diga el equipo de su amigo: caraquista o magallanero \n");
- fflush(stdin);
- gets(contacto1->equipo[10]);
- printf("Ingrese el telefono: ");
- fflush(stdin);
- gets(contacto1->telefono[10]);
- system("cls");
- printf("\n");
- }
- break;
- /*******************************************/
- /*******************************************/
- /*** MUESTRA LOS CONTACTO DE LA AGENDA *****/
- /*******************************************/
- /*******************************************/
- case 2:
- {
- system ("cls");
- for (contadorELIMINAR=0; contadorELIMINAR<numerodeamigos; contadorELIMINAR++)
- /***abre el for */ {
- printf("\nEl nombre es: %s \n", &contacto1->nombre[contadorELIMINAR]);
- printf ("el equipo es: %s \n",&contacto1->equipo[contadorELIMINAR]);
- printf ("el telefono: %s \n",contacto1->telefono[contadorELIMINAR]);
- } /**cierra el for**/
- system("pause");
- } /**cierra el case*/
- break;
- /*******************************************/
- /*******************************************/
- /****** MUESTRA CONTACTOS CARAQUISTAS *******/
- /*******************************************/
- /*******************************************/
- case 3:
- {
- for(x=0; x < numerodeamigos; x++)
- {
- if(strcmp(contacto1->equipo[x],"caraquista") == 0)
- {
- printf("los contactos caraquista son");
- printf("\nEl nombre es: %s \n",contacto1->nombre[x]);
- printf ("el telefono: %s \n",contacto1->telefono[x]);
- }
- }
- }
- break;
- /*******************************************/
- /*******************************************/
- /****** MUESTRA CONTACTOS MAGALLANERO *******/
- /*******************************************/
- /*******************************************/
- case 4:
- {
- for(y = 0; y < numerodeamigos; y++)
- {
- if(strcmp(contacto1->equipo[y],"magallanero") == 0)
- {
- printf("los contactos magallanero son");
- printf("\nEl nombre es: %s \n", contacto1->nombre[y]);
- printf ("el telefono: %s \n",contacto1->telefono[y]);
- }
- }
- break;
- case 5:
- /****/
- {
- char busca[40];
- system("cls");
- fflush(stdin);
- printf("\nBuscar contacto\n Ingrese el nombre del contacto:");
- gets(busca);
- for(x=0;x<numerodeamigos;x++){
- if(strcmpi(busca,contacto1->nombre[x])==0){
- printf("\nNombre: %s\n", contacto1->nombre[x]);
- printf("Telefono %s\n", contacto1->telefono[x]);
- }
- }
- }break;
- /******/
- case 6:
- {
- char busca1[40];
- system("cls");
- fflush(stdin);
- printf("\n eliminar contacto \n Ingrese el nombre del contacto:");
- gets(busca1);
- for(x=0;x<numerodeamigos;x++){
- if(strcmpi(busca1,contacto1->nombre[x])==0){
- printf("\nNombre: %s\n", contacto1->nombre[x]);
- printf("Telefono: %s\n", contacto1->telefono[x]);
- printf("Equipo: %s\n", contacto1->equipo[x]);
- printf("ELIMINADO");
- strcpy(contacto1->nombre[x],"");
- strcpy(contacto1->telefono[x],"");
- strcpy(contacto1->equipo[x],"");
- }
- }
- }break;
- }/**cierra el caso 4*/
- } /***cierra el do***/
- }/*** cierra el main **/
- while(numero<9);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement