0
[Solved] Pig Latin task - failed every test
I made the solution for Pig Latin task, but it was failed on every test. For example the first test failed, but my output and the answer are the same. I can't select the answer to check it for the spaces after sentence, but i checked for one space after and it was wrong too (my solution originally not add space after last word). Maybe i didn't checked all the cases of input to pass 3, 4 and 5 tests but i don't know why 1 and 2 tests failed. I think it's something about '\0' or something i don't know. Can someone help? https://code.sololearn.com/c1QjCuuuJYbJ/?ref=app
3 Answers
+ 1
In line number 7, for loop condition, instead of <=, put < only......
Edit:
Not at end but spaces adding in between.. So guessed write..
+ 4
Niko ,
What Jayakrishna told will fix the bug.
You could reduce a lot of debugging pain if you used at() method instead of overloaded [ ] operator.
[ ] operator won't check for bounds. but at() method will throw std::out_of_range exception if index is <0 or >=length.
+ 1
Thanks guys, now it's solved.
P.S.
I just used to use VS debug on PC, which always tells me if I went out of range, and [] was for me more readable. But now I will certainly use at() method, thanks for answers.