+ 1

Code coach :Military time

My solution to code coach problem Military time shows wrong answers in the three hidden test cases. I have tried to fix all of the probable complexities.But still having wrong answer on the cited testcases. Any insight or common error determining will help a lot. Here is my code: https://www.sololearn.com/coach/70?ref=app

20th Sep 2020, 7:01 AM
Nayeem Islam Shanto...ą¦¶ą¦¾ą¦Øą§ą¦¤
Nayeem Islam Shanto...ą¦¶ą¦¾ą¦Øą§ą¦¤ - avatar
3 Answers
+ 2
"A string in C is an array of characters that ends with a NULL character '\0'. For this reason, you must declare the array size to be at least one character longer than the expected string length." https://www.sololearn.com/learn/C/2936/ The problem seems to be that AP didn't have enough room for the string (due to the reason stated above) and used some of the space that was previously assigned to "int b" variable, overriding it's value with a wrong one(maybe the representation of the null character itself but I'm just making assumptions). Increase the length of char AP[] and you will get the correct output. I've never coded in C and the ouput might be compiler dependant so take the previous paragraph with reserve. What you have to know is: "Always ensure that your string have room for the null character". Nayeem Sorry for my late reply. Include the programming language (C) in relevant tags. Take it into account when you ask a question next time.
20th Sep 2020, 9:11 PM
Kevin ā˜…
+ 4
When we click that link we see the code coach problem and our own solution. We are unable to see yours. You have to copy the solution and save it as a new code in CodePlayground. Then copy the code link and paste it here(the same way you did with the code coach problem link). That way we will be able to see your code and help you.
20th Sep 2020, 7:58 AM
Kevin ā˜…
+ 1
Thank you kevin for your response. I'v got your point. But I also have fixed an issue with the sololearn compiler. My code gives correct output for every possible tricky testcases in Cpp droid compiler. But it is not generating correct output for any of the testcases in the Sololearn code playground. But why? Can you help me? Here is my code: https://code.sololearn.com/cN4uuOINE2Pp/?ref=app May be silly to anyone -Because I'm a new programmer.
20th Sep 2020, 11:12 AM
Nayeem Islam Shanto...ą¦¶ą¦¾ą¦Øą§ą¦¤
Nayeem Islam Shanto...ą¦¶ą¦¾ą¦Øą§ą¦¤ - avatar