导读 您好,现在程程来为大家解答以上的问题。函数中的形式参数是全局变量,函数的形参都属于全局变量相信很多小伙伴还不知道,现在让我们一起来看...
您好,现在程程来为大家解答以上的问题。函数中的形式参数是全局变量,函数的形参都属于全局变量相信很多小伙伴还不知道,现在让我们一起来看看吧!
1、static变量和main函数外面定义的变量为全局变量,比如#include"stdio.h"int a=3,b=5;//全局变量max(int a,int b){ int c; c=a>b?a:b; return c;}main(){ int a=8; printf("%d",max(a,b));}附图 还有max(int a,int b){int c;//局部,运行完函数后c占用的内存空间就被释放。
2、即c消失了c=a>b?a:b;return c;}main(){ extern int a,b;//extern此处为全局变量,或者这样定义static int a,b; printf("%d",max(a,b));}int a=3,b=5;。
本文就为大家分享到这里,希望小伙伴们会喜欢。
标签: