I have been tasked to do a ROT13 encryption function and everything looks fine except that it outputs 52 characters even when I have specified 26 characters in the array. Can anyone help me figure out what's the problem?
printf will output an array of characters until it finds the character with the numerical value of zero. That is how printf knows it has reached the end of the string.
If you build a char array for use with printf, you must ensure you put a zero value at the end.
That works, but I'm still puzzled. If what you said is true then why did the codes below work? Isn't the last character for the str the NULL character?