Possible Duplicate:
how does array[100] = {0} set the entire array to 0?
how to initialize a char array?
In c++, I want to initialize char array to 0s array.
Will "char a[4096] = {0};"
do this?
Possible Duplicate:
how does array[100] = {0} set the entire array to 0?
how to initialize a char array?
In c++, I want to initialize char array to 0s array.
Will "char a[4096] = {0};"
do this?
Yes it will... but keep in mind that a char
being 0
is ASCII NULL
... if you want it initialized to all '0'
(character 0's) that won't work.
In this case:
memset(a, '0', 10);
Would be a better way to go... or
std::fill(std::begin(a), std::end(a), '0');
Would be better yet.
Yes.
(And this answer has at least 30 characters as well.)