Przykłady C Exercise 41 - statyczne
100 przypadki klasycznego języka C
Tytuł: Nauka definicji statycznej zmiennej wykorzystania statyczne.
Program Analysis: Brak.
Kod źródłowy:
// Created by www.w3big.com on 15/11/9. // Copyright © 2015年 本教程. All rights reserved. // #include<stdio.h> int main() { void fun(); for(int i=0;i<3;i++) fun(); return 0; } void fun() { int i=0; static int static_i=0; printf("i=%d\n",i); printf("static_i=%d\n",static_i); i++; static_i++; }
Powyższy przykład wyjście jest:
i=0 static_i=0 i=0 static_i=1 i=0 static_i=2