Salve a tutti !! Ho un problema con l'allocazione in coda alla lista non so perche ma mi da errore (error: invalid operands to binary == (have 'Tlista' {aka 'struct Slista'} and 'void *') alla riga 44 ( if (*l==NULL)) nella funzione aggiungiInCoda mi potete dare una mano!!
rigrazio tutti in anticipo per le risposte
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
typedef struct Slista{
char par[25];
struct Slista *next;
}Tlista;
void crealista(Tlista *l);
void aggiungiInCoda(Tlista* l,char* T);
void stampalista(Tlista* l);
int main()
{
char testo[2000];
char *token;
Tlista *l;
printf("inserire testo massimo 2000 caratteri1:\n");
gets(testo);
crealista(l);
token=strtok(testo," ");
while(token!=NULL){
aggiungiInCoda(l,token);
token=strtok(NULL," ");
}
stampalista(l);
return 0;
}
void crealista(Tlista *l){
l=NULL;
}
void aggiungiInCoda(Tlista *l,char* T){
Tlista* p1;
if(*l==NULL){
*l=malloc(sizeof(Tlista));
strcpy(*l->par,T);
*l->next=NULL;
return;
}
p1=*l;
à
while(p1->next!=NULL){
p1=p1->next;
}
p1->next=malloc(sizeof(Tlista));
p1=p1->next;
strcpy(p1->par,T);
p1->next=NULL;
}
void stampalista(Tlista* l){
while (l != NULL) {
printf("%s ", l->par);
l = l->next;
}
}