Juin Posted January 3, 2010 at 08:00 PM Report Share #303909 Posted January 3, 2010 at 08:00 PM 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 More sharing options...
Localhost Posted January 3, 2010 at 08:03 PM Report Share #303911 Posted January 3, 2010 at 08:03 PM Muito provavelmente as comparações são de tipos diferentes, daí a incompatibilidade. here since 2009 Link to comment Share on other sites More sharing options...
Juin Posted January 3, 2010 at 08:04 PM Author Report Share #303912 Posted January 3, 2010 at 08:04 PM procura é uma cadeia de caracteres e os dados tambem .... Link to comment Share on other sites More sharing options...
OldCoder Posted January 3, 2010 at 08:06 PM Report Share #303913 Posted January 3, 2010 at 08:06 PM Pois, parece-me que tencionas comparar apontadores a caracteres, e não caracteres. Declara char *procura em vez de char procura, e não só te livras do warning, como o algoritmo funciona como queres. Link to comment Share on other sites More sharing options...
Juin Posted January 3, 2010 at 08:14 PM Author Report Share #303916 Posted January 3, 2010 at 08:14 PM coloquei e estou a receber ... funcoes.c:553: warning: comparison of distinct pointer types lacks a cast Link to comment Share on other sites More sharing options...
Localhost Posted January 3, 2010 at 08:27 PM Report Share #303922 Posted January 3, 2010 at 08:27 PM Se queres comparar strings usa o strcmp here since 2009 Link to comment Share on other sites More sharing options...
Juin Posted January 3, 2010 at 08:29 PM Author Report Share #303923 Posted January 3, 2010 at 08:29 PM 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 More sharing options...
Localhost Posted January 3, 2010 at 08:31 PM Report Share #303924 Posted January 3, 2010 at 08:31 PM No primeiro post, dados pareceu-me um vector de structs e neste último deixou de ser? Não será antes: dados[ i ]? here since 2009 Link to comment Share on other sites More sharing options...
OldCoder Posted January 3, 2010 at 08:55 PM Report Share #303936 Posted January 3, 2010 at 08:55 PM Podes postar uma declaração da estrutura Livro? Eu tive a impressão de que os membros seriam char*, mas com esse erro não tenho mais a certeza. Link to comment Share on other sites More sharing options...
Localhost Posted January 3, 2010 at 09:14 PM Report Share #303943 Posted January 3, 2010 at 09:14 PM 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 More sharing options...
OldCoder Posted January 3, 2010 at 10:35 PM Report Share #303982 Posted January 3, 2010 at 10:35 PM 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 More sharing options...
TheDark Posted January 4, 2010 at 02:57 AM Report Share #304006 Posted January 4, 2010 at 02:57 AM Ele tinha o índice, mas [ i ] é a tag BBCode para itálico. Como não pôs tags code, o BBCode comeu o índice. Logo, o problema não era esse (como se pode ver agora). @Juin: qual é a linha 555? Desaparecido. Link to comment Share on other sites More sharing options...
Localhost Posted January 4, 2010 at 04:50 PM Report Share #304068 Posted January 4, 2010 at 04:50 PM Ah sim, não prestei atenção a esse pequeno pormenor, mas já deve estar resolvido. here since 2009 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now