Jump to content

funcoes.c:551: warning: comparison between pointer and integer


Juin
 Share

Recommended Posts


Livro ProcurarAssociativa(char procura, int index){
    int i;
    Livro dados[i], d;
    for(i=0; i<index; i++){
        if(procura == dados[i].requisitante )
            EscreverProposta(dados[i], index);
        if(procura == dados[i].autores)
            EscreverProposta(dados[i], index);
        if(procura == dados[i].coleccao )
            EscreverProposta(dados[i], index);
        if(procura == dados[i].editor )
            EscreverProposta(dados[i], index);
        if(procura == dados[i].titulo )
            EscreverProposta(dados[i],  index);
    }
}

Estou a ter estes erros...

funcoes.c:551: warning: comparison between pointer and integer

funcoes.c:553: warning: comparison between pointer and integer

funcoes.c:555: warning: comparison between pointer and integer

funcoes.c:557: warning: comparison between pointer and integer

funcoes.c:559: warning: comparison between pointer and integer

Link to comment
Share on other sites

pois era o k estava a fazer mas recebo...

        if(i<index && strcmp(dados[i].titulo, procura)!=0)
            EscreverProposta(dados[i],index);
        if(i<index && strcmp(dados[i].requisitante, procura)!=0)
            EscreverProposta(dados[i],index);
        if(i<index && strcmp(dados[i].autores, procura)!=0)
            EscreverProposta(dados[i],index);
        if(i<index && strcmp(dados[i].coleccao, procura)!=0)
            EscreverProposta(dados[i],index);
        if(i<index && strcmp(dados[i].editor, procura)!=0)
            EscreverProposta(dados[i],index);

funcoes.c:555: warning: passing arg 1 of `strcmp' from incompatible pointer type

Link to comment
Share on other sites

OldCoder, ele estava a ter o problema devido ao facto de estar a comparar strings com o operador ==.

Agora o último erro era devido a ele não estar a colocar o indice para identificar qual era a estrutura dentro do array de estruturas, como colocou no primeiro post. Se ele já pôs o indice já deve compilar sem warnings.

here since 2009

Link to comment
Share on other sites

OldCoder, ele estava a ter o problema devido ao facto de estar a comparar strings com o operador ==.

Agora o último erro era devido a ele não estar a colocar o indice para identificar qual era a estrutura dentro do array de estruturas, como colocou no primeiro post. Se ele já pôs o indice já deve compilar sem warnings.

Agora vi! Obrigado pelo esclarecimento. Não tinha prestado atenção ao índice.

Se não houve mais reacções do autor do post original, o problema deve estar mesmo resolvido.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.