一、認清函數的真相
1、函數的由來
程序 = 數據 + 算法
C程序 = 數據 + 函數
2、函數的意義
模塊化程序設計
C語言中的模塊化
3、面向過程的程序設計
# 面向過程是一種以過程為中心的編程思想
# 首先將復雜問題分解為一個個容易解決的問題<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+o6OhobfWveK5/brztcTOysziv8nS1LC01dWyvdbo0ruyvbK9zeqzyTwvcD4KPHA+o6Ohobqvyv3Kx8Pmz/K5/bPM1Nqjw9Pv0dTW0LXEzOXP1jwvcD4KPHA+o6Ohob3ivvbOyszitcTDv9K7uPayvdbov8nS1NPDuq/K/cC0yrXP1jwvcD4KPHA+M6GiyfnD97rNtqjS5TwvcD4KPHA+o6OhobPM0PLW0LXEyfnD97/J0tTA7b3izqrUpM/IuObL37Hg0uvG98q1zOW1xLTm1NqjrMjno7qx5MG/o6y6r8r9o6y1yLXIPC9wPgo8cD6jo6Ghs8zQ8tbQtcS2qNLlw/fIt9a4yr6x4NLrxvfKtczltcTS4tLlPC9wPgo8cD7J+cP3us22qNLlsqKyu8/gzayjoaOho6E8L3A+CjxwPsq1wP2jujwvcD4KPHA+Ly8gZ2xvYmFsLmM8YnI+Ci8vIGludCBnX3ZhciA9IDA7IC8vILao0uU8L3A+CjxwPjxicj4KI2luY2x1ZGUgPHN0ZGlvLmg+PC9wPgo8cD48YnI+CmV4dGVybiBpbnQgZ192YXI7IC8vyfnD99K7uPbN4rK/seTBvzxicj4KPGJyPgp2b2lkIGYoaW50IGksIGludCBqKTsgLy/J+cP30ru49s3isr+6r8r9PGJyPgo8YnI+CmludCBtYWluKCk8YnI+Cns8YnI+CiAgICBpbnQgZyhpbnQgeCk7PGJyPgogICAgPGJyPgogICAgZ192YXIgPSAxMDs8YnI+CiAgICA8YnI+CiAgICBmKDEsIDIpOzxicj4KICAgIDxicj4KICAgIHByaW50Zig="%d\n", g(3));
return 0;
}
void f(int i, int j) // 定義
{
printf("i + j = %d\n", i + j);
}
int g(int x)
{
return 2 * x + g_var;
}
4、函數參數
# 函數參數在本質上與局部變量相同,都是在棧上分配空間
# 函數參數的初始值是函數調用時的實參值