What is the difference between using (char)0
and \'\\0\'
to denote the terminating null character in a character array?
Zero can mean a lot of different things in C. You should use the null character '\0', because then there can be no confusion over that your intention is string termination.
If you set a char to 0, that can mean null termination, but it can also mean that you are just using the char as an 8-bit integer for calculations, rather than as part of a string. This can be confused further if you are also using pointers in the same code and compare them against zero, which is then a null pointer.