cstringcomparison

(the letter) k is the same as f for some reason


input is a string and well...when input[0] is 'k', its apparently the same as 'f'? like clearly it should be false and not output "f detected" right? k seems to have a value of 107 and f seems to have a value of 102 so even when read as ints, it doesnt seem like it should be possible for them to be equal

enter image description here

enter image description here


Solution

  • Like what @DĂșthomhas commented, you have a semicolon after your if statement.

    if (input[0] == 'f');
    

    remove it and your code should work.

    if (input[0] == 'f')
    

    The semicolon effectively ends the if statement, so the block that follows is always executed, regardless of the condition.