If your array is not initialized, it contains the values โโof randoms and cannot be verified!
To initialize an array using 0 values:
int array[5] = {0};
Then you can check if the value is 0:
array[4] == 0;
When you compare with NULL, it compares with 0, because NULL is defined as an integer value of 0 or 0L.
If you have an array of pointers, it is best to use the nullptr value to check:
char* array[5] = {nullptr};
Geoffroy
source share