What's wrong with my dynamic stack?

1

I'm trying to make a dynamic stack, and for some reason something is wrong with the init function. You are giving the following error:

  

warning: conflicting types for 'init'

#include <stdio.h>
#include <stdlib.h>

typedef struct TipoCelular
{
    int elemento;
    struct TipoCelular *prox;
}elementoPilha;

typedef struct TipoTopo
{
    elementoPilha *Topo;
}Pilha;

int main()
{
    Pilha *p;

    init(p);

    if(empty(p))
        printf("Pilha vazia\n");

    return 0;
}

void init(Pilha *p)
{
    p->Topo = NULL;
}

int empty(Pilha *p)
{
    if(p->Topo == NULL)
        return 1;

    return 0;
}
    
asked by anonymous 18.03.2018 / 04:25

1 answer

4

It's because you used the init() function before it was set.

Put her definition before the main function or leave it where it is and add only its prototype before main .

void init(Pilha *p);
/* ... */
    
18.03.2018 / 09:10