As I know the string terminating character in C is '\0'.
Can we use '0' as the terminating character too? When I assign 0 to a specific index in a char array, and then use printf(), it prints only up to that specific index.
Hence, are both ways equivalent? Is the null character equal to the literal 0?
The only value that can be used as a null terminator is the numerical value 0.
0 is the numerical value 0.'\0' is also another way of representing the numerical value 0 in your code '0' is not the numerical value 0 (it's the digit zero) and cannot be used as a terminator.All strings literals implicitly contain the null terminator after their last visible character. In other cases, it may or may not be there automatically (depending on how the string was constructed), but you have to be sure that in every case the null terminator is there.