Skip to content

Commit cffded4

Browse files
committed
static variables
1 parent 3ecc42e commit cffded4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

prog.8.15.c

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Program to illustrate static and automatic variables
2+
3+
#include <stdio.h>
4+
5+
void auto_static (void)
6+
{
7+
int autoVar = 1;
8+
static int staticVar = 1;
9+
10+
printf ("automatic = %i, static = %i\n", autoVar, staticVar);
11+
12+
++autoVar;
13+
++staticVar;
14+
}
15+
16+
int main (void)
17+
{
18+
int i;
19+
void auto_static (void);
20+
21+
for ( i = 0; i < 5; ++i )
22+
auto_static ();
23+
24+
return 0;
25+
}

0 commit comments

Comments
 (0)