Question:
1)What is static identifier?
2)Where are the auto variables stored?
Answer:
static variables retain there value through out the execution. Source: CoolInterview.com
Answered by: sonu salim | Date: 11/20/2007
| Contact sonu salim
In C, if a local variable is declared static, a separate memory location is allocated for that variable. This variable retains the value between function calls, like a global variable. So next time when a function is called again it finds the old value. Also a local static variable is initialized only once. Eg:
void increment(void) { static int x = 1; x++; printf("%d ",x); } Here every time this function is called, x doesn't get initialized. So output would be 2 3 etc
Also if a global variable is declared static, it can only be accessed in that file. We cannot access it from other files as we can do for general global variable by using extern.
The default initial value of an uninitialized local static variable is zero. Source: CoolInterview.com
Answered by: meetali sharma | Date: 11/26/2007
| Contact meetali sharma
Static variables are local variable of a function,but it remain in main memory even after function goes out of scope.so when same function is called again it can use old value of static variable. auto variables are stored in main memory Source: CoolInterview.com
Answered by: Prashant Kumar Jha | Date: 1/11/2008
| Contact Prashant Kumar Jha
Static identifier are local variable of a function,but it remain in main memory even after function goes out of scope.so when same function is called again it can use old value of static variable.auto variables are stored in main memory. Source: CoolInterview.com
Answered by: Prashant Kumar Jha | Date: 1/11/2008
| Contact Prashant Kumar Jha
Static variables are stored in main memory, register variables in register, local variables in stack and global in data memory Source: CoolInterview.com
Answered by: sanchay | Date: 1/25/2008
| Contact sanchay
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|