When you define a variable in c as global i.e a global variable will be intialized automatically.
The variables declared of type int, float, double will be initialized to 0 and 0.0 respectively.
Any pointer declared to be global will be initilized to NULL.
Some of the compilers give a warning on initialization of global variables.
It is very important to initialize local variables especially pointers . Local variables contain junk values and will result in unexpected behaviour. Sometimes unintialized pointers lead to crash due to segmentaion faults.
The variables declared of type int, float, double will be initialized to 0 and 0.0 respectively.
Any pointer declared to be global will be initilized to NULL.
Some of the compilers give a warning on initialization of global variables.
It is very important to initialize local variables especially pointers . Local variables contain junk values and will result in unexpected behaviour. Sometimes unintialized pointers lead to crash due to segmentaion faults.
No comments:
Post a Comment