#include <stdio.h> int main() { int i = 520; printf("before, i = %d ", i); for (int i = 0; i < 10; i++) { printf("%d ", i); } printf("after, i = %d ", i); return 0; }
#include <stdio.h> void a(); void b(); void c(); int count; void a() { count++; } void b() { count++; } void c() { count++; } int main() { a(); b(); c(); b(); printf("被包了%d次 ", count); return 0; }
#include <stdio.h> void func(); int a, b = 520; void func() { int b; a = 880; b = 120; printf("In func, a = %d, b = %d ", a, b); } int main() { printf("In main, a = %d, b = %d ", a, b); func(); printf("In main, a = %d, b = %d ", a, b); return 0; }
extern关键字报错;
#include <stdio.h> void func(); void func() { extern count; count++; } int count = 0; int main() { func(); printf("%d ", count); return 0; }