Thread: Global and static global

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Raj 89's Avatar
    Join Date
    Nov 2012
    Location
    Chennai, TamilNadu
    Posts
    16

    Global and static global

    Hi,

    What is the difference between static and global static variable?
    I am not able to find any differences. Well they both seem the same to me.
    Do they differ in storage or the place where they are stored?

    Code:
    #include <stdio.h>
    
    unsigned int a ;
    static unsigned int b ;
    
    int main(void )
    {
    printf("\nGlobal : %u and %u\n",a,&a) ;
    printf("\nStatic Global : %u and %u\n",b,&b) ;
    return 0 ;
    }
    Please explain me with an example.
    Last edited by Raj 89; 11-23-2012 at 01:49 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. static global variable and static extern global variable
    By gunjansethi in forum C Programming
    Replies: 8
    Last Post: 01-12-2011, 01:00 AM
  2. static global & global variables
    By aqeel in forum C Programming
    Replies: 1
    Last Post: 09-25-2009, 12:32 PM
  3. static global
    By rajkumarmadhani in forum C Programming
    Replies: 19
    Last Post: 01-15-2008, 01:07 PM
  4. Replies: 2
    Last Post: 10-02-2004, 10:12 AM
  5. Static global variable acting as global variable?
    By Visu in forum C Programming
    Replies: 2
    Last Post: 07-20-2004, 08:46 AM