+ 10

Please help: I don't understand.... [solved]

Output problem https://code.sololearn.com/cYwJL6Bwm5zu/?ref=app

9th May 2018, 10:57 AM
Uni
Uni - avatar
4 Answers
+ 9
So I wrote the exact same code a few days ago and in the output I got the string I wanted followed by a lot of characters (I don't know were from) and other times I got errors....it seemed that it alternated between these possibilities almost randomly....but now it works pretty good....anyone has an explanation please?
9th May 2018, 10:59 AM
Uni
Uni - avatar
+ 6
Thank you all for your help ! 👍✌🙏 It helped me a lot !The problem was indeed the conversion I suppose (not sure) but now it works just fine!😄
9th May 2018, 1:45 PM
Uni
Uni - avatar
+ 3
Uni The code is working for me. But I don't know if the algorithm is what you indend it to be. I believe inside the for loop you what to show only a - z, A - Z , 0 - 9 and SPACE characters. But to show characters 0 - 9 you should use: (int)s[i] <= 57 && (int)s[i] >= 48 NOT (int)s[i] <= 9 && (int)s[i] >= 0 because 57 is the ascii value for 9 and 48 the ascii for 0. try it.
9th May 2018, 11:24 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
Everything is fine here. I thing the problem must be in explicit conversion that you may forget in your earlier code. An alternative way to implement it... https://code.sololearn.com/c0QMq7LCG75Q/?ref=app
9th May 2018, 11:05 AM
Alpha Rays
Alpha Rays - avatar