day7 coding: 变量存储、预处理

This commit is contained in:
2023-07-11 19:52:53 +08:00
parent 1ad50f4df7
commit ff10f99477
22 changed files with 302 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
#include "help.h"
// 内部函数
static void _show_sum(int a, int b, int c)
{
printf("%d + %d = %d\n", a, b, c);
}
// 全局函数
void twoNumAdd(int a, int b)
{
_show_sum(a, b, a + b);
}
+7
View File
@@ -0,0 +1,7 @@
#include <stdio.h>
// 内部函数
static void _show_sum(int a, int b, int c);
// 全局函数
void twoNumAdd(int a, int b);
+13
View File
@@ -0,0 +1,13 @@
#include "help.h"
int main()
{
for (int i = 1; i < 3; i++)
{
for (int j = 1; j <= i; j++)
{
twoNumAdd(i, j); // 可以调用 help.c 的外部函数
// _show_sum(i, j, i + j); // 不能调用 static 修饰的内部函数
}
}
}