hi im studing on i have this work and its giving me this error:

main.c||In function 'get_jogos':|
main.c|75|warning: implicit declaration of function 'get_endereco'|
main.c|75|warning: assignment makes pointer from integer without a cast|
main.c|76|warning: assignment makes pointer from integer without a cast|
main.c|122|error: conflicting types for 'get_endereco'|
main.c|75|note: previous implicit declaration of 'get_endereco' was here|
main.c||In function 'add_jogo':|
main.c|143|warning: initialization from incompatible pointer type|
main.c|149|warning: passing argument 2 of 'strcmp' makes pointer from integer without a cast|
mingw\bin..\lib\gcc\mingw32\4.4.1........\include\string.h|43|note: expected 'const char *' but argument is of type 'char'|
main.c|149|warning: passing argument 2 of 'strcmp' makes pointer from integer without a cast|
\mingw\bin..\lib\gcc\mingw32\4.4.1........\include\string.h|43|note: expected 'const char *' but argument is of type 'char'|
main.c|158|warning: passing argument 2 of 'get_endereco' makes pointer from integer without a cast|
main.c|122|note: expected 'char *' but argument is of type 'char'|
main.c|162|warning: passing argument 2 of 'get_endereco' makes pointer from integer without a cast|
main.c|122|note: expected 'char *' but argument is of type 'char'|
main.c|167|warning: passing argument 2 of 'get_endereco' makes pointer from integer without a cast|
main.c|122|note: expected 'char *' but argument is of type 'char'|
main.c|168|warning: passing argument 2 of 'get_endereco' makes pointer from integer without a cast|
main.c|122|note: expected 'char *' but argument is of type 'char'|
||=== Build finished: 1 errors, 10 warnings ===|

the code is below i appreciate the help :)

/*
 * File:   main.c
 * Author: User
 *
 * Created on 17 de Maio de 2012, 15:09
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "equipa.h"
#include "campeonato.h"
#include "data.h"
#include "jogo.h"
#include "listadatajogo.h"
#include "listpontoord.h"

/*
 *
 */

 // EQUIPAS

typedef struct equipacabecalho {
    int n_equipa;
    Equipa *next;
 }equipa_cabecalho;
typedef struct jogocabecalho {
    int n_jogo;
    Jogo *next;
 }jogo_cabecalho;

void get_equipas(equipa_cabecalho* ponteiro){
    FILE *fp;
    fp=fopen("equipas.txt", "r");


    char nome[30];
    char local[30];
    int pontuacao;
    int i=0;
    while(fscanf(fp, "%s %s %d",nome,local,&pontuacao)!=EOF){
        i++;
        Equipa* equipa;
        equipa=(Equipa*) malloc(sizeof(Equipa));
        strcpy(equipa->Nome,nome);
        strcpy(equipa->Local,local);
        equipa->Pontuacao=pontuacao;
        ponteiro->n_equipa=i;
        equipa->next=ponteiro->next;
        ponteiro->next=equipa;
        //printf("%s %s %d \n",nome,local,pontuacao);
    }
    fclose(fp);


}
void get_jogos(jogo_cabecalho* ponteiro,equipa_cabecalho* ponteiro2){
    FILE *fp;
    fp=fopen("jogos.txt", "r");

    char eq1[30];
    char eq2[30];
    int eq1res;
    int eq2res;
    int dia,mes,ano;

    int i=0;
    while(fscanf(fp, "%s %s %d %d %d %d %d",eq1,eq2,&eq1res,&eq2res,&dia,&mes,&ano)!=EOF){
        i++;

        Jogo* jogo;
        jogo=(Jogo*) malloc(sizeof(Jogo));

        jogo->visitado=get_endereco(ponteiro2,eq1);
        jogo->visitante=get_endereco(ponteiro2,eq2);
        jogo->pontos_visitado=eq1res;
        jogo->pontos_visitante=eq2res;
        Data data;
        data.dia=dia;
        data.mes=mes;
        data.ano=ano;
        jogo->data=data;
        ponteiro->n_jogo=i;
        jogo->next=ponteiro->next;
        ponteiro->next=jogo;
        //printf("%s %s %d \n",nome,local,pontuacao);
    }

}

void cria_lista_equipa(equipa_cabecalho** ponteiro){
    (*ponteiro) =(equipa_cabecalho*) malloc(sizeof(equipa_cabecalho));
    if((*ponteiro)!=NULL){
        (*ponteiro)->n_equipa=0;
        (*ponteiro)->next=NULL;

    }
}

void imprime_equipas(equipa_cabecalho * ponteiro){

    Equipa *aux=ponteiro->next;

    while(aux!=NULL){
        printf("%s",aux->Nome);
        aux=aux->next;
    }
}

// JOGOS


void cria_lista_jogos(jogo_cabecalho** ponteiro){
    (*ponteiro) =(jogo_cabecalho*) malloc(sizeof(jogo_cabecalho));
    if((*ponteiro)!=NULL){
        (*ponteiro)->n_jogo=0;
        (*ponteiro)->next=NULL;
    }
}

Equipa * get_endereco(equipa_cabecalho* ponteiro,char (*nome)){

    Equipa *aux=ponteiro->next;

    while(aux!=NULL){
        char str[30];
        strcpy(str,nome);
        if(strcmp(aux->Nome,str)!=0){

            return aux;
            printf("passei aki");

        }
        aux=aux->next;
    }
}
void add_jogo(jogo_cabecalho* ponteiro,equipa_cabecalho *ponteiro2,char eq1,char eq2,int eq1res,int eq2res,int dia,int mes,int ano){

    //verifica se a equipa existe
    int verifica=0;
    int count=0;
    Equipa *aux=ponteiro->next;

    while(aux!=NULL||count!=2){
            char str[30];
            strcpy(str,aux->Nome);

            if(strcmp(str,eq1)!=0||strcmp(str,eq2)!=0);
                count++;
            aux=aux->next;

    }

    if(count==2){
        Jogo *aux=(Jogo*)malloc(sizeof(Jogo));

        if(get_endereco(ponteiro2,eq1)!=NULL){

            verifica++;
        }
        if(get_endereco(ponteiro2,eq2)!=NULL){

            verifica++;
        }
        if(verifica==2){
            aux->visitado=get_endereco(ponteiro2,eq1);
            aux->visitante=get_endereco(ponteiro2,eq2);
            aux->pontos_visitado=eq1res;
            aux->pontos_visitante=eq2res;
            Data data;
            data.ano=ano;
            data.dia=dia;
            data.mes=mes;
            aux->data=data;
            aux=aux->next;
            //aux->next
        }


    }



}
void menu(){

}

int main(int argc, char** argv) {

    equipa_cabecalho* lista_equipas;
    cria_lista_equipa(&lista_equipas);

    get_equipas(lista_equipas);
    imprime_equipas(lista_equipas);

    jogo_cabecalho* lista_jogos;
    cria_lista_jogos(&lista_jogos);
    get_jogos(&lista_equipas,&lista_jogos);
    add_jogo(lista_jogos,lista_equipas,"benfica","porto",3,0,12,06,2012);


    return (EXIT_SUCCESS);
}

While I have only looked at this briefly, I can tell you that the main problem stems from this error here:

main.c|75|warning: implicit declaration of function 'get_endereco'|

What this means is that you haven't declared the function get_endereco() at that point of the source file yet, and the compiler can only guess what the return type f the function is. By default, the return type of an undeclared function is assumed to be int, hence the errors immediately following this one:

main.c|75|warning: assignment makes pointer from integer without a cast|
main.c|76|warning: assignment makes pointer from integer without a cast|

The error that comes up after that occurs when you finally do reach the implementation for get_endereco(); because the compiler has already generated a default function return prototype for the function, it gets confused when it then sees the real function return type:

main.c|122|error: conflicting types for 'get_endereco'|

The solution for this (and possibly for several other problems) is to add a function prototype before the functions that call get_endereco(). I would in fact recommend adding prototypes for all of the functions (except main(), which has a pre-defined type), just to ensure that the return types and parameters are correctly known to the compiler beforehand:

void get_equipas(equipa_cabecalho* ponteiro);
void get_jogos(jogo_cabecalho* ponteiro,equipa_cabecalho* ponteiro2);
void cria_lista_equipa(equipa_cabecalho** ponteiro);
void imprime_equipas(equipa_cabecalho * ponteiro);
void cria_lista_jogos(jogo_cabecalho** ponteiro);
Equipa * get_endereco(equipa_cabecalho* ponteiro,char (*nome));
void add_jogo(jogo_cabecalho* ponteiro,equipa_cabecalho *ponteiro2,char eq1,char eq2,int eq1res,int eq2res,int dia,int mes,int ano);
void menu();

This is a good practice in any case, and one you'd do well to get into the habit of.

thanks you are the man thats solves the problem i will use your advise and do this all time

This article has been dead for over six months. Start a new discussion instead.