CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
Diffenentiate between an internal static and external static variable?
Category C Interview Questions
Rating (4.7) By 27 users
Added on 10/22/2004
Views 4800
Rate it!
Answers:

An internal static variable is declared inside a block with static storage class whereas an external static variable is declared outside all the blocks in a file.An internal static variable has persistent storage,block scope and no linkage.An external static variable has permanent storage,file scope and internal linkage.



Internal static variable is block scope and persist there value between calls. External static variables are file scope. Normally when you need to declare global variable, it is good practices if you declare it as static for that particular file and provide interface function to access that global variable. This avoids accidentally modification of global variable.
e.g.

file 1

static int count;

int get_count()
{
return count;
}

void set_count(int cnt)
{
count = cnt;
}

so here other files can access count only by these functions.



 Posted by: Vaibhav R Gaonkar    

Contact Vaibhav  R  Gaonkar  Contact Vaibhav R Gaonkar


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
What are advantages and disadvantages of external storage class?
View Answer
Differentiate between a linker and linkage?
View Answer
What are the characteristics of arrays in C?
View Answer
When does the compiler not implicitly generate the address of the first element of an array?
View Answer
What is modular programming?
View Answer
What is a function and built-in function?
View Answer
What is an argument ? differentiate between formal arguments and actual arguments?
View Answer
What is the purpose of main( ) function?
View Answer
What are the advantages of the functions?
View Answer
What is a method?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/977/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.62