codice:
#include <stdio.h>
#include <stdlib.h>
#define MAXNUM 3
typedef struct CELLA *LISTA;
typedef struct BIN{
int chiave;
char valore;
}BIN;
typedef struct CELLA{
BIN info;
LISTA* next;
}CELLA;
void mk_bintab(BIN* input, LISTA *tab);
void in_coda(BIN bin, LISTA* testa);
void print(LISTA *l);
int main(){
LISTA array[MAXNUM]={NULL, NULL, NULL};
BIN input[8];
input[0].chiave=2;
input[0].valore='A';
input[1].chiave=1;
input[1].valore='B';
input[2].chiave=1;
input[2].valore='C';
input[3].chiave=3;
input[3].valore='D';
input[4].chiave=2;
input[4].valore='E';
input[5].chiave=1;
input[5].valore='F';
input[6].chiave=3;
input[6].valore='G';
input[7].chiave=2;
input[7].valore='H';
mk_bintab(input, array);
print(array);
}
void mk_bintab(BIN* input, LISTA *tab){
int i;
for(i=0;i<8;i++){
in_coda(input[i], (LISTA*)tab[input[i].chiave-1]);
}
}
void in_coda(BIN bin, LISTA* testa){
while(testa!=NULL){
printf("Testa non nulla...\n");
testa=(*testa)->next;
}
printf("Testa nulla...\n");
LISTA aux=(LISTA) calloc(1, sizeof(struct CELLA));
aux->info.chiave=bin.chiave;
aux->info.valore=bin.valore;
aux->next=NULL;
testa=aux;
}
void print(LISTA *l){
int i;
for(i=0;i<MAXNUM;i++){
while(l[i]!=NULL){
printf("%d\n%c\n", l[i]->info.chiave, l[i]->info.valore);
l[i]=l[i]->next);
}
printf("NULL\n");
}
}
Nella funzione che crea problemi l'ho sostituito. Provvederò nelle altre...