Computer Science, asked by TbiaSamishta, 1 year ago

To declare and initialized a empty string, a 10 element character array named x, we have char x[10] = “ “ ; What will be the other way for the same?

Answers

Answered by Brainlycurator
1

To declare and to initialize an empty string in zero sized array. The zero sized arrays can be determined from the number specified between square braces.

char my_string [0] = ‘\0’ .  

For a 10 element character array named x it can be written as follows,

char my_string [10] = ‘\0’.  

In above example size of array 10 is specified between square braces. ‘\0’ is the explicit NULL CHARACTER which is used indicates the termination of the string.

Similar questions