如何在一个文件中定义一个C函数,然后从另一个文件中调用它? [英] How can I define a C function in one file, then call it from another?
本文介绍了如何在一个文件中定义一个C函数,然后从另一个文件中调用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
func1.c
中定义了一个函数,我想从文件 call.c
,我该如何实现这一目标?提前致谢!
解决方案
您可以在函数中声明 func1.h
,并在 call.c
中添加 #includefunc1.h
。然后你可以将 func1.c
和 call.c
连接在一起(具体取决于哪个C系统)。
Say I define a function in the file func1.c
, and I want to call it from the file call.c
,
how would I accomplish this? Thanks in advance!
解决方案
You would put a declaration for the function in the file func1.h
, and add #include "func1.h"
in call.c
. Then you would compile or link func1.c
and call.c
together (details depend on which C system).
这篇关于如何在一个文件中定义一个C函数,然后从另一个文件中调用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文