Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default values in array

Tags:

c++

arrays

What are default values for arrays like this:

char c[20];

?

BTW, Are there any?

like image 314
oneat Avatar asked Jan 16 '11 20:01

oneat


1 Answers

If declared at namespace scope then c will have static storage scope and will be zero-initialized so every element of c will have value '\0'.

If declared in a function then c will not be initialized. The initial value of the elements of c will be indeterminate.

like image 194
CB Bailey Avatar answered Oct 12 '22 23:10

CB Bailey