Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

(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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading