#include <stdio.h>
void subFunc();
int gVar1 = 150; //全局变量1
int main(void)
{
int num = 250; //局部变量
printf("这是在main程序中:\n");
printf("gVar1 = [%d]\n", gVar1);
printf("num = [%d]\n", num);
// printf("gVar2 = [%s]\n", gVar2);
// printf("buffer = [%s]\n", buffer);
subFunc();
return 0;
}
//这个就是只能在后面的subFun()中使用,不能用在main()中
char *gVar2 = "I am a global variable."; //全局变量2
void subFunc()
{
char *buffer = "I am in subFunc."; //局部变量
printf("\n这是在subFunc程序中:\n");
printf("gVar1 = [%d]\n", gVar1);
// printf("num = [%d]\n", num);
printf("gVar2 = [%s]\n", gVar2);
printf("buffer = [%s]\n", buffer);
return ;
}
|