Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links


External Storage Class in C

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 23-01-2010
Member
 
Join Date: Dec 2009
Posts: 33
External Storage Class in C

Sponsored Links
Hello, Friends. I am working in the multinational company as programmer in C language. I know the C is the basic of all languages but still I don't have the well knowledge of the C language. Because of that I am finding little difficult to work on the C language. So, I just would like to know about the External Storage Class, what is the purpose of the External Storage Class And how they can work. I also want to know that how can I declare External Storage Class. Can anyone is there who can help me?

Reply With Quote
  #2  
Old 23-01-2010
absolute55's Avatar
Member
 
Join Date: Nov 2005
Posts: 1,321
External Storage Class

Hi, External Storage Class variable is used to give reference to all program files that are visible, of a global variable. External Storage Class variable points the variable name that has been previously defined at storage location. External Storage Class variable can be used when you have the multiple files and defines the function or global variable that is also used in other files, to give the reference of variable that is defined. External Storage Class variable are defined by using the 'extern' keyword.
Reply With Quote
  #3  
Old 23-01-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,382
blush External Storage Class

The following code of lines staes you that the storage classes and their scope :
#include <stdio.h>
void fun1(void);
void fun2(void);
int glbvar = 10;
int main()
{
printf("\n****storage classes and scope****\n");
glbvar = 20;
printf("\nVariable glbvar, in main() = %d\n", glbvar);
fun1();
printf("\nVariable glbvar, in main() = %d\n", glbvar);
fun2();
printf("\nVariable glbvar, in main() = %d\n", glbvar);
return 0;
}
int glbvar2 = 30;
void fun1(void)
{
char glbvar;
glbvar = 'A';
glbvar2 = 40;
printf("\nIn funct1(), glbvar = %c and glbvar2 = %d\n", glbvar, glbvar2);
}
void fun2(void)
{
double glbvar2;
glbvar = 50;
glbvar2 = 1.234;
printf("\nIn fun2(), glbvar = %d and glbvar2 = %.4f\n", glbvar, glbvar2);
}
Reply With Quote
  #4  
Old 23-01-2010
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,278
Re: External Storage Class in C

There is another program that helps you to learn about the External Storage Class :
File 1: mainn.c
int cnt=5;
main()
{
write_extern();
}

File 2: writ.c
void write_extern(void);
extern int cnt;
void write_extern(void)
{
printf("count is %i\n", cnt);
}

Now, compile above two files as follows :
gcc main.c write.c -o write
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "External Storage Class in C"
Thread Thread Starter Forum Replies Last Post
How to swap the usb storage with external sd Nicoloid Portable Devices 6 26-12-2011 11:08 AM
What are the Static storage class in C Garett Software Development 3 23-01-2010 10:07 AM
Register Storage class in C Gaauge Software Development 3 23-01-2010 09:06 AM
Automatic storage class in C Tailor Software Development 3 23-01-2010 08:07 AM
Meaning of storage class specifiers in C++ Language KALYAN23 Software Development 3 07-11-2009 05:01 PM


All times are GMT +5.5. The time now is 02:47 PM.