TDIIII Posted October 6, 2009 at 10:03 PM Report Share #290366 Posted October 6, 2009 at 10:03 PM char i[50]; char v[]="read"; printf("insira uma palavra"); fgets(i,50,stdin); if(i==v) ........ o que eu pretendia é que o if detecta-se quando o utilizador digite a mesma string que v mas assim como tenho no codigo nao detecta ou seja se eu digitar no teclado read a variavel i armazenar a string "read" e executar o if caso o que esteja no i ser igual ao que esta no v alguem me pode ajudar? Link to comment Share on other sites More sharing options...
Rui Carlos Posted October 6, 2009 at 10:06 PM Report Share #290367 Posted October 6, 2009 at 10:06 PM Não podes comparar strings com o operador de igualdade. Precisas de usar a função strcmp (ou algo equivalente). Rui Carlos Gonçalves 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