DEV Community

Discussion on: String in C

Collapse
 
raddevus profile image
raddevus

This is a nice write-up with good small examples.
You say that the array on line 3 cannot be changed but I don't believe the array in Line 1 can be either, right?
Also, it would be nice to know the length of the final strings and/or arrays.
For example you state at the beginning that a string is a 1 dimensional array of characters terminated by \0. Is the terminating character included in the length of the string?
Is the length of str[] 4 or 5? It'll be 4, right? Doesn't include \0.
thanks

Collapse
 
sanskrati01 profile image
Sanskrati Jain

The first and the third way are the same except one is easier to type. So the comment for the third is also valid for the first.
And yes, it will not include '\0' in length. It reduces the length by 1 but it is still there.