I'm reading a book C progaming faq's. Here is passage of the book
Automatic variables are variables defined inside a function or block of code without the static keyword. These variables have undefined values if you don’t explicitly initialize them. If you don’t initialize an automatic variable, you must make sure you assign to it before using the value.
Here is my code:
#include <stdio.h>
int main (int argc, const char * argv[])
{
{
int x;
printf("%d", x);
}
}
The result of printf
is 0. Why is the variable initialized?