I have the following
char mem_pool[1024*1024*64]; int main() {
I am trying to get a complete understanding of how mem_pool will be initialized. After many searches, my findings are:
- this is static initialization (not like in the
static keyword, but as in "run before program execution - during the static initialization phase") - it will work in 2 stages: initialization of zero and initialization by default (the second phase will do nothing)
- it is a POD array, therefore, the default initialization for each element should be applied, but due to the previous two points we will not have an array of undetectable values (as we would with
char ar[N] in the function area), but an array of zeros.
Can someone help me expose what is guaranteed by the language and correct me if I am wrong?
I also thought about doing any of the following
char mem_pool[1024*1024*64] {}; char mem_pool[1024*1024*64] = "";
I suspect this is the best / recommended practice, but now I need to understand my initial question.
source share