I'm creating a function to find the position of a character and for some reason it can't see when the characters are equal.
int findCharacterPosition(char *string, char *character)
{
for(int position = 1; position <= dbLen(string); position++)
{
if(dbMid(string, position) == character)
{
return position;
}
}
return -1;
}
But when I modify the code as follows for some reason it works
int findCharacterPosition(char *string, char *character)
{
for(int position = 1; position <= dbLen(string); position++)
{
//Here I converted it to ASCII code
if(dbAsc(dbMid(string, position)) == dbAsc(character))
{
return position;
}
}
return -1;
}
Does anybody know why this is?