Can anyone please let me know the difference between below two c statements in terms of initialization, scope of table and any other.
NOTE:Both are global variables.
unsigned int *table[100] = {NULL};
static unsigned int *table[100] = {NULL};
Can anyone please let me know the difference between below two c statements in terms of initialization, scope of table and any other.
NOTE:Both are global variables.
unsigned int *table[100] = {NULL};
static unsigned int *table[100] = {NULL};
table is an array of pointers of type unsingned int in both the declarations.static the visibility of the array is restricted only to the file in which you are declaring this array.The link will help
Similarity:
Difference:
Note that if you declared both in the same file then static declaration will get highest preference. i.e. Assigning any value to table pointer will get static initialization.
unsigned int *table[100] = {NULL};
table is an array of pointer to unsingned int and initialize entire array elements to NULL.
static unsigned int *table[100] = {NULL};//declared as static means initialized only once
table is an array of pointer to static unsingned int and initialize entire array elements to NULL.