Showing posts with label c. Show all posts
Showing posts with label c. Show all posts

Tuesday, 29 May 2012

what is Extern keyword?

extern keyword in c

Keyword extern is used for declaring extern variables in c. This modifier is used with all data types like int, float, double, array, pointer, structure, function etc.
Important points about extern keyword:
1. It is default storage class of all global variables as well all functions. For example, Analyze following two c code and its output:
(a)
#include <stdio.h>
int i;    //By default it is extern variable
int main(){
    printf("%d",i);
    return 0
}

Wednesday, 14 September 2011

IT

Using Static Variables


 Problem

You want a local variable to retain its value between invocations of a function.

Solution

Declare the variable as static:
function track_times_called( ) {
    static $i = 0;
    $i++;
    return $i;
}