1
I’m trying to create a list structure using struct.
Only when compiling my code, I get an error because even specifying the type Lista, he’s in some kind of trouble.
Follow the full code:
#include <stdio.h>
#include <conio.h>
struct lista {
    int info;
    struct lista* prox;
};
typedef struct lista Lista;
int main(void)
{
    Lista* l; 
    l = list_new();
    l = list_add(l, 23);
    l = list_add(l, 45);
    list_print ( l ); 
    
    return(0);
}
Lista* list_new (void)
{
    return NULL;
}
Lista* list_add (Lista* l, int i)
{
    Lista* novo = (Lista*) malloc(sizeof(Lista));
    novo -> info = i;
    novo -> prox = l;
    return novo;
}
void list_print (Lista* l)
{
    do {
        printf(“%d\t”,l->info);
        l = l->prox;
    } while (l != NULL); 
}
The error is giving on line 22:
[Error] Conflicting types for 'list_new':
List* list_new (void)
Do you know that you can also vote on everything on the site, in addition to accepting an answer in your questions? Take a look at [tour].
– Maniero