String initialization with and without explicit trailing terminator,
What is the difference between
char str1 = " ";
char str2 = "";
Since you already declared the sizes, the two declarations are exactly equal. However, if you do not specify the sizes, you can see that the first declaration makes a larger string:
char a = "a "; char b = "a"; printf("%i %in", sizeof(a), sizeof(b));
This is because a ends with two nulls (the explicit one and the implicit one) while b ends only with the implicit one.
That’s the answer String initialization with and without explicit trailing terminator, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.
The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you