Hello! I make a simple function for compare two strings, the function is like a
strcmp(), of
string.h. My function is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
int CompareStr(char* str1, char* str2){
int i;
if ( strlen(str1) != strlen(str2) ) {
printf("As diferent!\n");
return 1;
}
else {
for (i = 0; i < strlen(str1); i++) {
if (str1[i] == str2[i]) {
printf("Equals!\n");
return 0;
}
else {
printf("As diferent!\n");
return 1;
}
}
}
return 0;
}
|
This function as right? I tested thid and work it. Thanks.
Last edited on
try this xD
1 2 3 4
|
int strCmp(char str1[], char str2[])
{
return strCmp(str1, str2) + 1;
}
|
Last edited on
@ascii
...and that is how you create a stack overflow. ;)
-Albatross
Last edited on