Salve, devo creare una lista linkata, e sono arrivato a questo:
codice:
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
struct Elenco;
typedef Elenco * puntElenco;
typedef struct Elenco{
char parola;
puntElenco next;
} Elenco;
puntElenco inserisci(puntElenco L, char word){
puntElenco q;
q=(puntElenco)malloc(sizeof(Elenco));
q->next=L;
strcpy(q->Elenco.parola,word);
q->next=L;
return(q);
}
main (){
puntElenco el_parole;
el_parole = NULL;
int scelta,a=1,vocali=0;
char word;
do{
system("cls");
printf("SCELTA OPERAZIONE \n");
printf("\nPREMI 1:-----------INSERISCI PAROLA---------------------\n");
printf("PREMI 2:-----------VISUALIZZA LISTA-----------------\n");
printf("PREMI 3:----------------USCITA-----------------\n");
printf("\nScelta: ");
scanf("%d",&scelta);
if(scelta==1){
system("PAUSE");
printf("Digita la parola da inserire: ");
scanf("%s",word);
el_parole=inserisci(el_parole,word);
}
} while(a!=0);
system("PAUSE");
return 0;
}
Solo che arrivati al comando di strcpy nella funzione inserisci, mi da questi errori:
codice:
In function `Elenco* inserisci(Elenco*, char)':
error: invalid conversion from `char' to `char*'
error: initializing argument 1 of `char* strcpy(char*, const char*)'
error: invalid conversion from `char' to `const char*'
error: initializing argument 2 of `char* strcpy(char*, const char*)'