amigos quien me puede ayudar a pasar este codigo con punteros y con memoria dinamica ???'
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
#include <string.h>
#define p printf
#define s scanf
struct contacto{
char equipo[40][80];
char nombre[40][80];
char telefono[40][80];
}c1;
int cont=0;
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;
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("cuantos amigos quiere agregar: ");
scanf("%i",&numerodeamigos);
for (contadorAGREGAR=0; contadorAGREGAR<numerodeamigos; contadorAGREGAR++)
{
system("cls");
printf("ingrese el nombre: ");
fflush(stdin);
gets(c1.nombre[contadorAGREGAR]);
printf("Diga el equipo de su amigo: caraquista o magallanero \n");
fflush(stdin);
gets(c1.equipo[contadorAGREGAR]);
printf("Ingrese el telefono: ");
fflush(stdin);
gets(c1.telefono[contadorAGREGAR]);
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", &c1.nombre[contadorELIMINAR]);
printf ("el equipo es: %s \n",&c1.equipo[contadorELIMINAR]);
printf ("el telefono: %s \n",c1.telefono[contadorELIMINAR]);
} /**cierra el for**/
system("pause");
} /**cierra el case*/
break;
/*******************************************/
/*******************************************/
/****** MUESTRA CONTACTOS CARAQUISTAS *******/
/*******************************************/
/*******************************************/
case 3:
{
for(x=0; x < numerodeamigos; x++)
{
if(strcmp(c1.equipo[x],"caraquista") == 0)
{
printf("los contactos caraquista son");
printf("\nEl nombre es: %s \n", &c1.nombre[x]);
printf ("el telefono: %s \n",c1.telefono[x]);
}
}
}
break;
/*******************************************/
/*******************************************/
/****** MUESTRA CONTACTOS MAGALLANERO *******/
/*******************************************/
/*******************************************/
case 4:
{
for(y = 0; y < numerodeamigos; y++)
{
if(strcmp(c1.equipo[y],"magallanero") == 0)
{
printf("los contactos magallanero son");
printf("\nEl nombre es: %s \n", &c1.nombre[y]);
printf ("el telefono: %s \n",c1.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,c1.nombre[x])==0){
printf("\nNombre: %s\n", c1.nombre[x]);
printf("Telefono %s\n", c1.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,c1.nombre[x])==0){
printf("\nNombre: %s\n", c1.nombre[x]);
printf("Telefono: %s\n", c1.telefono[x]);
printf("Equipo: %s\n", c1.equipo[x]);
printf("ELIMINADO");
strcpy(c1.nombre[x],"");
strcpy(c1.telefono[x],"");
strcpy(c1.equipo[x],"");
}
}
}break;
}/**cierra el caso 4*/
} /***cierra el do***/
}/*** cierra el main **/
while(numero<9);
}
aqui el codigo comienzando con los punteros
#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];
}contacto_t;
contacto_t * contacto1= malloc (sizeof(contacto_t))
int cont=0;
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;
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("cuantos amigos quiere agregar: ");
scanf("%i",&numerodeamigos);
for (contadorAGREGAR=0; contadorAGREGAR<numerodeamigos; contadorAGREGAR++)
{
system("cls");
printf("ingrese el nombre: ");
fflush(stdin);
gets(c1.nombre[contadorAGREGAR]);
printf("Diga el equipo de su amigo: caraquista o magallanero \n");
fflush(stdin);
gets(c1.equipo[contadorAGREGAR]);
printf("Ingrese el telefono: ");
fflush(stdin);
gets(c1.telefono[contadorAGREGAR]);
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->equipo[contadorELIMINAR]);
} /**cierra el for**/
system("pause");
} /**cierra el case*/
break;
/*******************************************/
/*******************************************/
/****** MUESTRA CONTACTOS CARAQUISTAS *******/
/*******************************************/
/*******************************************/
case 3:
{
for(x=0; x < numerodeamigos; x++)
{
if(strcmp(c1.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(c1.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,c1.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,c1.nombre[x])==0){
printf("\nNombre: %s\n", c1.nombre[x]);
printf("Telefono: %s\n", c1.telefono[x]);
printf("Equipo: %s\n", c1.equipo[x]);
printf("ELIMINADO");
strcpy(c1.nombre[x],"");
strcpy(c1.telefono[x],"");
strcpy(c1.equipo[x],"");
}
}
}break;
}/**cierra el caso 4*/
} /***cierra el do***/
}/*** cierra el main **/
while(numero<9);
}
¿A qué te refieres con "pasar"?...
Por cierto, para códigos tan largos deberías alojarlos aquí (http://pastebin.com/) y publicar solamente el enlace a él...
osea que este codigo lleve memoria dinamica y punteros amigos