c语言函数调用例子(c语言函数调用例子的方法)

发布时间:2025-12-10 23:10:15 浏览次数:1

c语言函数调用例

#include <stdio.h>#define LABEL '*'#define NAME "王五"#define AGE 35void printSplit(void);int main(){    printSplit();    printf("姓名:%s\n", NAME);    printf("年龄:%d\n", AGE);    printSplit();    return 0;}void printSplit(void) {    for (size_t i = 0; i < 10; i++)    {        putchar('*');    }    putchar('\n');}

注:printSplit函数在main函数后面,所以需要在前面进行申明。

结果:

**********姓名:王五年龄:35**********

函数参数

#include <stdio.h>void printSplit(int);int main(){    for (size_t i = 1; i < 10; i++)    {        printSplit(i);    }    return 0;}void printSplit(int width) {    for (size_t i = 0; i < width; ++i)    {        putchar('*');    }    putchar('\n');}

结果:

********************************************

看完了这篇文章,相信你对c语言函数调用例子的方法有了一定的了解,想了解更多相关知识,欢迎关注本站行业资讯频道,感谢各位的阅读!

c语言函数调用例子
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477