Storage classes in C Programming

1.auto
2.static
3.register
4.extern







auto:

#include<stdio.h>
void main()
{
auto int n=45;
printf("value is:%d",n);
}

output: value is:45


with static

#include<stdio.h>
void test()
{
static int n=0;
printf("%d ",n);
n++;
}
void main()
{
test();
test();
test();
}

output : 0 1 2


without static

#include<stdio.h>
void test()
{
        int n=0;
printf("%d ",n);
n++;
}
void main()
{
test();
test();
test();
}

output : 0 0 0


extern

program-1


#include<stdio.h>
extern void test();
extern  int n=0;
extern void test()
{
printf("demo test");
}

save the file  with  .c   (eg: MyTest.c)


program-2

#include"MyTest.c"
main()
{
test();
n=10;
printf("%d",n);
}


0 Comments