|
| ||||||||||
| Tags: c language, class, external storage |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| External Storage Class in C
|
|
#2
| ||||
| ||||
| 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. |
|
#3
| ||||
| ||||
|
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); }
__________________ Grand Theft Auto 4 PC Video Game |
|
#4
| ||||
| ||||
| 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 |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |