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

10th Aug 2020, 8:55 AM
Solus
Solus - avatar
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)
10th Aug 2020, 9:23 AM
Arsenic
Arsenic - avatar
+ 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
10th Aug 2020, 9:14 AM
Arsenic
Arsenic - avatar
+ 1
Arsenic Thanks. However, the program still cannot print false. Any idea as to why?
10th Aug 2020, 9:24 AM
Solus
Solus - avatar
+ 1
Arsenic Thanks a lot!!
10th Aug 2020, 9:40 AM
Solus
Solus - avatar