I'm trying to create a list structure using struct
.
But when I compile my code, I get an error because, even specifying Lista
, it has a problem.
Follow the complete 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 in line 22:
[Error] conflicting types for 'list_new':
List * list_new (void)