that an error in my .h , and i need a hint,which would be the problem?

Recommended Answers

All 4 Replies

How about giving us a hint with some code....

my code is:

echo "
#include<stdio.h>
#include<stdlib.h>

typedef struct tree {
  char letra;
  struct tree *l, *r;
} arbol;

arbol *crear_nodo(char val) {
  arbol *result = (arbol *)malloc(sizeof(arbol));
  result->l = result->r = NULL;
  result->letra = val;
  return(result);
}
void free_arbol(arbol *arb) {
  
  if (arb == NULL) return ;

  free_arbol(arb->r);
  free_arbol(arb->l);
  free(arb);
}
  
int agregar_letra_en_arbol(arbol *arb, char *t, char *s){ /* la idea es que con *t voy avanzando en la línea que obtengo de 						fgets y *s lo necesito para agregar la letra que se encuentra en  s[0] */

	if( *t=='\0' || *t=='\n') return 1 ;/// por si aca aunque no debería usarse, solo en caso de linea con esos no más

	if(arb == NULL){ arb=crear_nodo(' ');
			
			return agregar_letra_en_arbol(arb,t,s); } /* no sé sise usará, ya que declaré el árbol de todas maneras al incio con el ' ' .*/

	else {

		if( *t=='.'){ // me voy a la izquierda para colocar la letra

			if(arb->l == NULL){
				arbol *aux =crear_nodo(' ');
				arb->l=aux;
				if( *(t+1)=='\0' || *(t+1)=='\n') {arb->l->letra=s[0]; return 1;} /*en el caso que ya estuviera se 	pone de nuevo no más, es decir se reemplazará. */  /*s[0] es la primera letra de línea*/
				
				return agregar_letra_en_arbol(arb->l,(t+1),s); // si no entra a if llama recursivamente
					} 

			else   // caso en que existe ese nodo
				if( *(t+1)=='\0' || *(t+1)=='\n') {arb->l->letra=s[0];return 1;}
				else return agregar_letra_en_arbol(arb->l,(t+1),s);

			}
		else {if( *t=='-'){ //derecha
				if(arb->r == NULL){
				 	arbol *aux =crear_nodo(' ');
					arb->r=aux;
					if( *(t+1)=='\0' || *(t+1)=='\n'){ arb->r->letra=s[0];return 1;}
					return agregar_letra_en_arbol(arb->r,(t+1),s);	
					}

				else  {
					if( *(t+1)=='\0' || *(t+1)=='\n'){ arb->r->letra=s[0];return 1;}/* si existe nodo se reemplaza ahí la letra por ' ' que es el char por defecto al crearse */
					else return agregar_letra_en_arbol(arb->r,(t+1),s);}

					}
			else{
						printf(" la línea no está en Código Moorse");
						return 1;	}	
			}
	}
    }

}

" ;

What an absolute mess...Use proper indenting and I'm sure you'll find your problem..

Also why dont you guys write your code incrementally ?
Then if you get a compiler error, it is quite easy to spot the reason

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.