Reputation: 13
I would like to initialize an array of strings with \0. Is it right to do it like this?
char first[1024][1024] = {'\0'};
Upvotes: 0
Views: 262
Reputation: 41017
For a 2d array is better to use:
char first[1024][1024] = {{'\0'},{'\0'}};
or better yet (as suggested by @haccks):
char first[1024][1024] = {{'\0'}};
in order to avoid warnings.
Upvotes: 2
Reputation: 1372
If it is a static array, say, a global array, you do not need to do any initialization and the values of the array are set to 0 by default.
Upvotes: -1