Results 1 to 4 of 4

Thread: External Storage Class in C

  1. #1
    Join Date
    Dec 2009
    Posts
    33

    External Storage Class in C

    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?

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    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. #3
    Join Date
    Oct 2005
    Posts
    2,393

    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);
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    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

Similar Threads

  1. Solution for external storage
    By Rubeen in forum Hardware Peripherals
    Replies: 5
    Last Post: 22-02-2010, 10:54 AM
  2. What are the Static storage class in C
    By Garett in forum Software Development
    Replies: 3
    Last Post: 23-01-2010, 11:07 AM
  3. Register Storage class in C
    By Gaauge in forum Software Development
    Replies: 3
    Last Post: 23-01-2010, 10:06 AM
  4. Automatic storage class in C
    By Tailor in forum Software Development
    Replies: 3
    Last Post: 23-01-2010, 09:07 AM
  5. Meaning of storage class specifiers in C++ Language
    By KALYAN23 in forum Software Development
    Replies: 3
    Last Post: 07-11-2009, 06:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,766,026.94675 seconds with 16 queries