函数其他内容

This commit is contained in:
2023-06-04 03:09:34 +08:00
parent c371e8f6a7
commit a575016375
10 changed files with 193 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.c
+24
View File
@@ -0,0 +1,24 @@
#include <stdio.h>
// 定义一个局部变量
// 在函数内部定义的,不加任何修饰的变量都是局部变量
void myfun()
{
int num = 100;
num++;
printf("num = %d\n", num);
return ;
}
int main(int argc, char *argv[])
{
// 局部变量只能在定义的函数内部使用,生命周期相对较短,函数结束,局部变量就会释放
// printf("num = %d\n", num);
myfun();
myfun();
myfun();
return 0;
}