I'm trying to get the difference of two characters. My problem is when I input the 2nd character it gives a different value even if the character is just the same as the first input:
Example below. I input "a" as first char and then "a" again for the second but it gives different value
int main(){
char* flet;
char* slet;
printf("Input first character:");
scanf("%c", &flet);
fflush(stdin);
printf("Input Second character:");
scanf("%c", &slet);
printf("First Char is \"%c\" and Second Char is \"%c\".", flet,slet);
DiffofChar(flet,slet);
}
void DiffofChar(char* letter1, char* letter2){
int theDiff;
theDiff = letter1 - letter2;
printf("The difference of %c (%d) and %c (%d) is %d.", letter1, letter1, letter2, letter2, theDiff);
}
Output:
