多文件函数调用

//函数调用
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ void print_my_name();//函数声明 ,尽量每个函数都要声明,养成好习惯 int main(int argc, char *argv[]) { printf_my_name();//调用子函数 return 0; } //子函数定义 void printf_my_name() { printf("kinson"); }


//多文件函数调用
/*
------------主函数---------------- 
 调用其他文件的函数 
*/

#include "b.h"//把自己写的头文件包含进来 


int main() 
{
    int ans = sum(2,2); //调用其他文件的函数
    printf("%d",ans); 
    return 0;
}

 

/*
------主函数与子函数之间链接的桥梁------ 
*/ 
#ifndef _B_h_//固定格式,文件名大写
#define _B_H_//固定格式,文件名大写

int sum(int x,int y);//函数声明

#endif//固定格式 

 

 

 


/*
-----------子函数-------------- 
*/ 
#include "b.h"//包含头文件

//头文件中声明的函数具体实现
int sum(int x,int y)
{
    return x*y;
} 

 



 

转载于:https://www.cnblogs.com/kinson/p/6826904.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值