0

I don't know what's wrong with this code

As you can tell by looking at the code below, I'm trying to reverse the order of q string (user input) but it's adding some symbols on its own when executed .. I'm not sure if the problem is in the sololearn playground compiler or in the cin of c++ https://code.sololearn.com/clB8sT3ZMv5S/?ref=app

28th Aug 2020, 1:12 PM
Med Anis Jbara
Med Anis Jbara - avatar
6 Answers
+ 3
There are two problems with the code. First, replace sizeof(ch) with ch.length(). Second, for loop should start with ch.length()-1, since ch is only valid from 0 to ch.length()-1.
28th Aug 2020, 1:44 PM
boonga
boonga - avatar
+ 2
sizeof(ch) will not return the number of characters entered.
28th Aug 2020, 1:35 PM
shashuri Magrease
shashuri Magrease - avatar
+ 1
~ swim ~ cool 😂
28th Aug 2020, 2:02 PM
Med Anis Jbara
Med Anis Jbara - avatar
0
Can anyone explain the difference between the size and length method ? Why did they make both methods do the same thing
28th Aug 2020, 1:58 PM
Med Anis Jbara
Med Anis Jbara - avatar