Which of the following declarations are equivalent?
char string_var[10] = "Hello";
char string_var[10] = {'H', 'e', 'l', 'l', 'o', '\0'};
char string_var[10] = {'H', 'e', 'l', 'l', 'o'};
char string_var[6] = "Hello";
char string_var[] = "Hello";
Consider the declarations:
char string_var[10] = "Hello";: Initializes the string "the easy way."
char string_var[10] = {'H', 'e', 'l', 'l', 'o', '\0'};: It is equivalent to the first string,
char string_var[10] = {'H', 'e', 'l', 'l', 'o'};: It is an array of characters, not a string. It is unique.
char string_var[6] = "Hello"; It creates a string with room for exactly the 5 characters in "Hello" and the null terminator
char string_var[] = "Hello";: It same as creates a string with room for exactly the 5 characters in "Hello" and the null terminator