day7 coding: 变量存储、预处理
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// 内部函数
|
||||
static void _show_sum(int a, int b, int c);
|
||||
|
||||
// 全局函数
|
||||
void twoNumAdd(int a, int b);
|
||||
@@ -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 修饰的内部函数
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user