我想调用一个驻留在func.c文件中的函数到main.c中,这是我的func.c
#include "func.h"
int func(int i) {
return ++i ;
}这是我的头文件func.h
int func(int i);这是我的主代码: main.c
#include <stdio.h>
#include <stdlib.h>
#include "func.h"
main()
{
int res = func(3);
printf("%d\n",res);
system("pause");
}编译主代码时,我得到这样的错误:对'func‘的引用未定义。我的目标是从外部文件(不是同一编译单元的一部分)调用函数。该怎么做呢?谢谢!
发布于 2014-12-23 18:27:18
#include <stdio.h>
#include <stdlib.h>
#include "func.h" // change ( since func.h is not a slandered header file its a user define header file)
main()
{
int res = func(3);
printf("%d\n",res);
system("pause");
}https://stackoverflow.com/questions/27618235
复制相似问题