I have written a function which has two different options of what to return:
//function to compare the strings in function3
int compare(char* str, char* dest){
int answer;
int i;
int length;
length = strlen(str);
// int jlength;
// jlength = strlen(dest);
for(i=0; i<length; i++){
if(str[i] == dest[i]){
answer = 1;
}else {
answer = 2;
}
}
return answer;
}
I want to use this function later, and have different things happen depending on what the function has returned. Below are the relevant parts of how I have constructed that:
//compare the reversed str with the orignal, now stored in dest
compare(str, dest);
int function3answer;
if(compare == 1){
function3answer = 1;
}else{
function3answer = 2;
}
return function3answer;
}
When I compile I get the error:
warning: comparison between pointer and integer [enabled by default]
Adding single quotes around the 1 does not help (and also isn't really what I want because I am not referencing part of an array) nor does taking it down to one equals sign (this produces a different warning).
Thanks so much!
Aucun commentaire:
Enregistrer un commentaire