Solo, what the star is that? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Solo, what the star is that?

You cannot Use "for (int i=0;i<text.length();i++)" because compiler won't compare i and text.length(). BUT "int length=text.length()" will work in "for (int i=0; i<length;i++)"! I've spent An hour because of this mistake!!! https://code.sololearn.com/cDWasqMUI61X/?ref=app

19th Apr 2020, 7:54 AM
Egor Cry
Egor Cry - avatar
2 Respostas
+ 2
That is because the length() method returns a size_type, which is an unsigned type, and the compiler doesn't "like" comparing integers of different signedness because it can easily be a potential source for mistakes. But usually that should only raise a warning, not an error, so the program should still run.
19th Apr 2020, 8:02 AM
Shadow
Shadow - avatar
+ 4
I suggest you to attach your code link within your thread Description. Partial code like that doesn't help much with analysis. See this if you don't know how to share links šŸ‘‡ https://www.sololearn.com/post/75089/?ref=app
19th Apr 2020, 8:01 AM
Ipang