0
C Code returning random characters at end.
After I print out the final output it returns a random string of characters. The code takes in an input that is replaced with a flipped alphabet version of the text. https://code.sololearn.com/cXgYh7bpYRN6/#c
2 ответов
+ 6
You can add
output[i] = '\0';
After your loop to correct the issue.
It's printing out the garbage values left behind in those memory locations, since it doesn't see the termination of the C string.
+ 3
You forgot to terminate the string, i.e., forgot to add '\0' at the end of the string. So printf() has no idea until when to stop printing the string.