Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: willy1855 en 9 Mayo 2012, 08:43 am



Título: Listas y Sublistas..Ayuda!!
Publicado por: willy1855 en 9 Mayo 2012, 08:43 am
Buenas Gente
Saludos a todos otra vez recurro a este buen foro que me ayudo la otra vez
mi problema es el siguiente estoy haciendo un programa de listas y sublistas que maneja conjuntos tengo un código pero me marca un error a la hora compilar si alguien me puede ayudar.! gracias!

Citar
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <alloc.h>

//estructuras...
struct sublista{
int dato;
struct sublista*siguiente;
};

struct lista{
char nom[50];
struct lista*sig;
struct sublista*sub;
};


FILE*in;
FILE*pro;

char cad[100];
char cad2[100];
char cad3[100];
char c[1];


struct sublista*R=NULL;
void insertar_sublista (int dato)
{
struct sublista *p, *n;
unsigned int a = 0, b = 0;


if (R == NULL)
{
n = (struct sublista*)malloc(sizeof(struct sublista));
while(a < strlen(cad2))
{
n -> dato = dato;
a++;
}
n -> siguiente = NULL;
//n -> sub = NULL;
R = n;
}
else
{
p = R;
while(p -> siguiente != NULL)
{
p = p -> siguiente;
}
n = (struct sublista*)malloc(sizeof(struct sublista));
while(b < strlen(cad2))
{
n -> dato = dato;
b++;
}
n -> siguiente = NULL;
//n -> sub = NULL;
p -> siguiente = n;
}
}


struct lista*r=NULL;
void insertar_lista (char nom[20])
{
struct lista *p, *n;
unsigned int a = 0, b = 0;


if (r == NULL)
{
n = (struct lista*)malloc(sizeof(struct lista));
while(a < strlen(cad2))
{
n -> nom[a] = nom[a];
a++;
}
n -> sig = NULL;
n -> sub = NULL;
r = n;
}
else
{
p = r;
while(p -> sig != NULL)
{
p = p -> sig;
}
n = (struct lista*)malloc(sizeof(struct lista));
while(b < strlen(cad2))
{
n -> nom = nom;
b++;
}
n -> sig = NULL;
n -> sub = NULL;
p -> sig = n;
}
}


//empieza a cortar en el archivo
void cortar()
{
char nom[50];
unsigned int i = 0, j = 1;
strcpy (cad3, "");
strcpy (nom,"");


fgets(cad,100,in);

while (i < strlen (cad))
{
if (cad!='(')
{
c[0]=cad;
strcat (cad3, c);
i++;
j++;
}
else
{
i=strlen (cad);
}
}
while (j < strlen (cad))
{
if(cad[j]!=')')
{
if (cad[j]!=',')
{
c[0]=cad[j];
strcat (cad2,c);

}//","

else
{
strcpy(nom,cad2);
insertar_lista(nom);
strcpy(cad2, " ");
}//")"
}//termina if
j++;
}//fin ciclo while
}//funcion


void mostrar()
{
int c;
while ( (c = fgetc(in)) != EOF)
   {
      fputc(c, pro);
   }
}


void sublista_union(struct sublista*a,*b) //EN ESTA LINEA ME MARCA EL ERROR QUE ME DICE "EXPECTED" A QUE SE REFIERE ESTE ERROR NO LE ENTIENDO.
{
struct sublista*p,*t;
int l=0;
t=a;
p=b;
   while(p!=NULL)
   {
      while(t!=NULL)
      {
         if(p->dato==t->dato)
         {
            l=1;
         }//if
         t=t->siguiente;
      }//while
         if(l==0)
         {
            insertar_sublista(t,p->dato);
         }//if
      p=p->siguiente;
      t=a;
   }//while
return(t);
}

void lista_union(struct lista*j,*k)
{
struct lista*p,*t;
int l=0;
t=j;
p=k;
   while(p!=NULL)
   {
      while(t!=NULL)
      {
         if(p->nom==t->nom)
         {
            l=1;
         }//if
         t=t->sig;
      }//while
         if(l==0)
         {
            insertar_lista(t,p->nom);
         }//if
      p=p->sig;
      t=j;
   }//while
return(t);
}



void main()
{
in=fopen("maestro.txt","r+");
pro=fopen("pro.txt","w+");

cortar();
mostrar();

fclose(in);
fclose(pro);
getch();
}


Título: Re: Listas y Sublistas..Ayuda!!
Publicado por: xiruko en 9 Mayo 2012, 10:26 am
cuando el error dice algo de expected, tiene q ver con q a la funcion le pasad un argumento erroneo, segun lo que tu has definido. no he leido el code ya que estoy desde el movil y es algo incomodo, pero revisa los argumentos d las funciones y las llamadas a estas. seguramente el error tenga que ver con algun puntero.


Título: Re: Listas y Sublistas..Ayuda!!
Publicado por: durasno en 9 Mayo 2012, 16:40 pm
Hola! mostra el error q t marca asi t podemos ayudar mejor