Find the answer to your Linux question:
Results 1 to 5 of 5
Hii there... what exactly does a storage class for a variable in C signify...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2005
    Location
    INDIA
    Posts
    28

    Storage Classes!!


    Hii there...
    what exactly does a storage class for a variable in C signify

  2. #2
    Just Joined!
    Join Date
    Jun 2005
    Location
    Canada, Halifax
    Posts
    86
    Automatic storage is local to the block of code and is lost after said block of code is exited from. Static storage retains its value between calls to the block of code.

  3. #3
    Just Joined!
    Join Date
    Jun 2005
    Location
    INDIA
    Posts
    28
    Hii...i got it
    thanks for the reply..
    one more thing....is a globally declared variable is of type "extern" ?

  4. #4
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    Kind of...you can optionally use extern to refer to a global variable:

    Code:
    int global;
    
    int main() {
        extern int global;
    }
    I think you need extern if the variable's declared in a different file, but I'm not entirely sure.

  5. #5
    Just Joined!
    Join Date
    Jun 2005
    Location
    Canada, Halifax
    Posts
    86
    The "extern" storage class specifier indicates that storage for the object is declared elsewhere and provides linkage to it. The "external" declaration can be omitted if the the variable is declared in the same source file and before the function that references it. If on the other hand your program spans more than one source file then this external linkage is required for the storage object to be visible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •