ruka_mendes Posted June 19, 2012 at 04:09 PM Report Share #464117 Posted June 19, 2012 at 04:09 PM (edited) Boas pessoal, tenho um problema, estou farto de googlar e não consigo resolver...isto dá-me um erro de conflicting types e nao consigo compilar...alguem me explica o que ta mal por favor? obrigado. #include <stdio.h> #include <string.h> int strcspn( char *s1, char *s2 ) { int i=0; int j=0; int flag = 1; while (i< strlen(s1) && flag == 1) { while(j<strlen(s2)) { if(s1[i]==s2[j]) { flag=0; } else { j++; } } i++; j=0; } return i; } int main() { printf("%d", strcspn("BJHM","ABM")); } A funcao strcspn(s1; s2) que calcula o comprimento do segmento inicial da string s1 que nao contem nenhum dos caracteres presentes em s2. Por exemplo: Com s1 = "BJHM" e s2 = "ABM" teria de retornar 3. Cumprimentos Edited June 19, 2012 at 05:12 PM by pmg GeSHi adicionado Link to comment Share on other sites More sharing options...
KiNgPiTo Posted June 19, 2012 at 04:42 PM Report Share #464128 Posted June 19, 2012 at 04:42 PM Isso acontece pois já existe uma função definida em string.h com o nome strcspn. Altera o nome e falta um return na função main... Link to comment Share on other sites More sharing options...
Flinger Posted June 19, 2012 at 04:54 PM Report Share #464133 Posted June 19, 2012 at 04:54 PM http://linux.die.net/man/3/strcspn Link to comment Share on other sites More sharing options...
ruka_mendes Posted June 19, 2012 at 04:58 PM Author Report Share #464134 Posted June 19, 2012 at 04:58 PM Really? Tanto tempo perdido e era só isso -.-' Não sabia que já fazia parte do string.h. Obrigado 😉 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