initialize array in c with 0 1

initialize array in c with 0

static char ZEROARRAY[1024]; // if declaration is in global scope or is static it will alredy be initialized to Zeroes
// OR
char ZEROARRAY[1024] = {0}; // Compiler fills unwritten entries with zeroes
// OR
memset(ZEROARRAY, 0, 1024); // Alternatively you could use memset to initialize the array at program startup:

Here is what the above code is Doing:
1. The first line declares a variable called ZEROARRAY of type char[1024].
2. The second line initializes the variable to all zeroes.
3. The third line uses memset to initialize the variable to all zeroes.

The first two lines are equivalent. The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at runtime, whereas the first two lines initialize the variable at compile time.

The first two lines are equivalent because the C standard says that if you declare a variable in global scope or as static, then the compiler must initialize it to all zeroes.

The third line is different because it initializes the variable at

Similar Posts