I have this program that should implement a hasheo function. But throw the following warning that is above:
warning: passing argument 1 of 'HashInsertar' from incompatible pointer type
When you try to pass the number entered by the user to the function HashInsertar
the warning above goes up and I do not know how to correct it. What can I do?
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define HASHMAX 10
typedef struct nodoL {
int info;
struct nodoL * sig;
} * lista;
//Definición de las Funciones
// DEFINICIÓN DE LAS FUNCIONES
//************* HASH **********
typedef lista Hash[HASHMAX];
int HashClave(int n);
void HashInsertar(Hash *H, int e);
void HashMostrar(Hash H);
void HashBuscar(Hash H, int n);
//******** LISTA *******
void enlistar (lista *L, int n);
int mostrar (lista L); /* muestra por pantalla los valores de L, en forma recursiva */
void borrar(lista *L, int n);
int HashClave ( int n)
{
return n%HASHMAX;
}
void HashInsertar (Hash *H, int e){
enlistar ((H)[HashClave(e)],e);
}
void HashMostrar(Hash H){
int i, n;
for (n=0;n<HASHMAX;n++){
printf("Hash [%d]: ",n);
i=mostrar(H);
if(i==0)printf("Lista vacia \n\n");
else printf("# \n\n");
}
}
void enlistar (lista *L, int n){
lista aux = (lista)malloc(sizeof(struct nodoL));
if(L==NULL){
aux -> info = n;
aux -> sig = *L;
*L=aux;
}
else{
if((*L)->info>n){
aux -> info = n;
aux -> sig = *L;
*L=aux;
}
else{
enlistar(&(*L)->sig,n);
}
}
}
int mostrar (lista L)
{
int i=0;
if(L!=NULL)
{
i=1;
printf("[%d]->",L->info);
mostrar(L->sig);
}
return i;
}
void borrar(lista *L, int n)
{
lista aux = *L;
lista ant = NULL;
if(aux==NULL)
{
printf("Error: Lista vacia");
}
else
{
while (aux->info!=n&&aux->sig!=NULL)
{
ant=aux;
aux=aux->sig;
}
if(aux->sig==NULL&&aux->info!=n)
printf("Error, caracter no se encuentra en la lista");
else
{
ant->sig=aux->sig;
free (aux);
}
}
}
int main()
{
int op=-1;
int i;
lista milista=NULL;
while(op)
{
system("cls");
printf("\t\tEjemplo de Hash\n\n\tSeleccione una opcion\n\n\t-1. Agregar elemento al frente\n\t-2. Mostrar lista\n\t-3. Borrar un elemento\n\t-0. Salir\n");
scanf("%d",&op);
switch(op)
{
case 1:
{
int numNuevo;
system("cls");
printf("Ingrese el numero para agregar a la lista:\n");
scanf("%d",&numNuevo);
system("cls");
HashInsertar(&milista,numNuevo); //<------- warning: passing argument 1 of HashInsertar from incompatible point type
getch();
break;
}
case 2:
{
system("cls");
printf("Los numeros cargados en la lista:\n\n");
i = mostrar(milista);
if(i==0)printf("La lista esta vacia \n\n");
else printf("# \n\n");
getch();
}
break;
case 3:
{
int n;
system("cls");
printf("Ingrese el numero para borrar de la lista:\n");
scanf("%d",&n);
system("cls");
borrar(&milista,n);
if(i==0)printf("Elemento borrado de la lista. Pulse cualquier tecla para regresar");
getch();
break;
}
}
}
getch();
return 0;
}