Initializing the string in C; Is the following useful?
Asked 07 September, 2021
Viewed 2.5K times
  • 55
Votes

I know how to initialize strings in C in two different ways.

char str[] = "abcd";

char str[] = {'a','b','c','d','' };

Clearly writing "abcd" instead of {'a','b','c','d','' } is time saving and comfortable.

Are there any particular reason that we can initialize the string like in the last line? Is it useful in some context or is it superfluous?

1 Answer