1 #include <iostream> 2 3 void test() { 4 static int a[4]; 5 for (int i = 0; i < 4; ++i) { 6 std::cout << a[i] << " "; 7 } 8 std::cout << std::endl << "--------" << std::endl; 9 a[3] = 4; 10 for (int i = 0; i < 4; ++i) { 11 std::cout << a[i] << " "; 12 } 13 std::cout << std::endl; 14 } 15 16 int main() { 17 test(); 18 std::cout << std::endl; 19 test(); 20 }
输出结果:
0 0 0 0 -------- 0 0 0 4 0 0 0 4 -------- 0 0 0 4