+ 2
Why can't my code print "false" ?
I'm trying to make an Isogram detector (for just one word). That is, the output should be true if there is no duplicate letters in a string, and vice versa. https://code.sololearn.com/co18VCjDS80l/#cpp I got a warning saying: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 63 | for (int zzz = 0; zzz < str.size(); zzz++) | ~~~~^~~~~~~~~~~~ How can I fix this? Also, I'm open to suggestions on how to simplify my super long code...
4 Answers
+ 1
And if you are wondering why your code is not returning "false" then you are comparing "str[i]" with everything not "zzz"(which is your loop variable)
+ 3
Nothing
It's just saying that you are comparing 2 different data types in statement (zzz < str.size() ) because size() function returns answer as "long unsigned int"
Just change "zzz" to long unsigned int to get rid of it
Here's the fixđ
https://code.sololearn.com/cijYAy1ysH67/?ref=app
+ 1
Arsenic Thanks. However, the program still cannot print false. Any idea as to why?
+ 1
Arsenic Thanks a lot!!