C - Does a static declaration reinitate the value when recalled?
I'm guesing not, but would a code of something like:
Code:
static int foo = 0; |
When in doubt about small things like this in C, I like to write a quick program to test the problem (it generally saves tons more time than posting on a forum):
Code:
#include <stdio.h> Code:
foo is: 0 BTW, setting a static variable to zero is unnecessary, since K&R's book indicates that static variables get automatically initialized to zero. |
Awesome. Perfect thanks. Yeah, I had considered writing a small program to test it, but I was working on another one and decided that someone would know on here so I could be lazy and not do it myself. Thanks a ton! Very descriptive answer.
|
All times are GMT -5. The time now is 04:50 AM. |