Error TESTE500K.c :(. text + 0x8f): undefined reference to 'INSERE'

0

Galera, I'm trying to create a list but are giving these errors
TESTE500K.c :(.text + 0x8f): undefined reference to 'INSERE'

TESTE500K.c: (. text + 0xa5): undefined reference to 'PRINT'

[Error] ld returned 1 exit status

I would have to do with String (char *) which is another problem, but I decided to test first with char only that it is not working.

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

    struct agenda {
        int tel;
        char nome;
        struct agenda *prox;
    };
    typedef struct agenda Agenda;
    typedef Agenda *Ponteiro;

    void INSERE (Ponteiro *, int , char);
    void IMPRIME (Ponteiro);


    int main (){
        Ponteiro inicio = NULL;
        int telefone;
        char NOME;
        int escolha;
        printf ("DIGITE: \n 1 para Inserir \n 2 para Imprimir \n 3 para Finalizar \n");
        scanf ("%d", &escolha);
        if (escolha == 1){
            printf ("DIGITE O NOME: \n");
            scanf ("%c", &NOME);
            printf ("DIGITE O NUMERO: \n");
            scanf ("%d", &telefone);
            INSERE (&inicio, telefone, NOME);

        }
        else if (escolha == 2){
            IMPRIME (inicio);
        }
        else {
            return 0;
        }
        void INSERE (Ponteiro *sPtr, int novo_telefone, char novo_nome){
            Ponteiro novo, anterior, atual;
            novo = malloc (sizeof(Agenda));
            if (novo != NULL){
                novo->tel = novo_telefone;
                novo->nome = novo_nome;
                anterior = NULL;
                atual = *sPtr; 
                while (atual != NULL){
                    anterior = atual;
                    atual = atual ->prox;
                    if (anterior == NULL) {
                        novo->prox = *sPtr;
                        *sPtr = novo;
                    }
                    else{
                        anterior->prox = novo;
                        novo->prox = atual;
                    }
                }
            }
        }
        void IMPRIME(Ponteiro atual) {
            if (atual == NULL)
                printf( "A Agenda esta vazia.\n\n" ) ;

            else {
                printf( "A lista eh:\n");
                while (atual != NULL) {
                    printf("%c", atual->nome);
                    printf("%d", atual->tel);

                    atual = atual -> prox;
                }
            }
    }
    }
    
asked by anonymous 14.06.2017 / 01:11

1 answer

0

After

 else {
        return 0;
    }

There should be one more key, which would close the main() function. Without the key, you're basically setting the IMPRIME() and INSERE() functions within main() , which is impossible in C, so functions are not being created, and your compiler does not know what to do. p>

It is also necessary that you remove the last key from the program, since that is where your program is currently running.

    
14.06.2017 / 01:58