I participated Google Code Jam 2019 Round 1C yesterday. Below was the part of the code.
char str[5]={r1,r2,r3,r4,r5};
printf("%s\n", str);
The judge gave Wrong Answer. But if I add the line str[5]='\0';
before print statement, It works.
Actually I checked running the program and it seems to be printing normally. Then, may I know why the judge is giving Wrong Answer and where It could have gone wrong? Can anyone please help by telling me the difference of printing string with null character and without null character? Can someone confirm if it will give always correct result?