Results 1 to 4 of 4

Thread: What are the Static storage class in C

  1. #1
    Join Date
    Dec 2009
    Posts
    22

    What are the Static storage class in C

    Hi, How are you all. I studying in the first year of the MS. I have to submit the project on the C language in my college. but I don't have the better knowledge of the C language. So, that makes me difficult in doing the project in the C language. So, I just to know about the Static Storage Class in C. I also want to know what is the purpose of the Static Storage Class And how they can work, how can I declare Static Storage Class. Can anyone help me to complete my project?

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Static storage class in C

    Hello, Static Storage class is the default storage class for global variables. Static Storage class can be initialized at the compile time and keeps it's value between the calls, in case of the local variables. Static Storage class variable could be initialized to zero by default. Static Storage class variable could be initialized to NULL in pointer. The scope of Static Storage class variable is identical to that of Automatic Storage class variables. The Static Storage class variables are defined using the keyword 'static' .

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Storage class in C

    Static obj can be external to all blocks or local to a block. But in case it retains their values reentering into function and across exit from function. The objects that are declared outside of all the blocks at the same level as function definitions are always uses the keyword static this gives them Internal Link. The value of the Static Storage class variable persists between different function calls. The value of the Storage class variable could not disappear once the function in which it can be declared becomes inactive. When you come out the program then only it is unavailable. I hope you understand.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: What are the Static storage class in C

    I think the following code of line helps you to understand the Static storage class :
    #include <stdio.h>
    #define MXNM 3
    void sm_up(void);
    int main()
    {
    int cnt;
    printf("\n*****static storage*****\n");
    printf("Key in 3 numbers to be summed ");
    for(cnt = 0; cnt < MXNM; cnt++)
    sm_up();
    printf("\n*****COMPLETED*****\n");
    return 0;
    }
    void sm_up(void)
    {
    static int summ = 0;
    int numm;
    printf("\nEnter a number: ");
    scanf("%d", &numm);
    summ += numm;
    printf("\nThe current total is: %d\n", summ);
    }

Similar Threads

  1. Static method in Abstract class
    By Anthony12 in forum Software Development
    Replies: 6
    Last Post: 12-08-2010, 10:22 AM
  2. External Storage Class in C
    By Agustíne in forum Software Development
    Replies: 3
    Last Post: 23-01-2010, 11:51 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. What is static data members of class?
    By Jaiwanti in forum Software Development
    Replies: 3
    Last Post: 20-11-2009, 10:48 AM

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,714,032,882.62524 seconds with 17 queries