本實例演示函數調用嵌套:main 調用 three_hellos,後者循環 3 次調用 hello_world。
// Created by www.runoob.com on 15/11/9.
// Copyright © 2015年 菜鳥教程. All rights reserved.
//
#include <stdio.h>
void hello_world(void) {
printf("Hello, world!\n");
}
void three_hellos(void) {
int counter;
for (counter = 1; counter <= 3; counter++)
hello_world();
}
int main(void) {
three_hellos();
}
Hello, world!
Hello, world!
Hello, world!
展示函數模塊化、代碼復用、調用棧基本概念。