C Exercise Example 43

100 Classic C Examples

Title:Learn another usage of static.

Program analysis:None.

Program source code:

Example

// Created by www.example.com on 15/11/9. // Copyright © 2015 Example. All rights reserved. // #include <stdio.h> int main() { int i,num; num=2; for(i=0;i<3;i++) { printf("num variable is %d\n",num); num++; { static int num=1; printf("Built-in module num variable is %d\n",num); num++; } } return 0; }

The output result of the above example is:

num 变量为 2 
内置模块 num 变量为 1
num 变量为 3 
内置模块 num 变量为 2
num 变量为 4 
内置模块 num 变量为 3

100 Classic C Examples

other extensions