Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

C access global variable same name

// C Program to demonstrate that we can access a global
// variable if we have a local variable with same name
#include <stdio.h>
  
// Global variable x
int x = 50;
  
int main()
{
    // Local variable x
    int x = 10;
    {
        extern int x;
        printf("Value of global x is %d
", x);
    }
    printf("Value of local x is %d
", x);
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #C #access #global #variable
ADD COMMENT
Topic
Name
6+8 =