在Xcode项目中,语言为C。
堆
main.c
这是heap_sort.c文件。
#include "heap_sort.h"
int sum(int a, int b)
{
return a + b;
}
这是heap_sort.h文件。
#ifndef heap_sort_h
#define heap_sort_h
#include <stdio.h>
#endif /* heap_sort_h */
这是我在Xcode中的代码截图。我只是想导入一个函数名 金额 到我的main.c文件。
这是main.c文件
#include <stdio.h>
#include "heap/heap_sort.h"
int main(int argc, const char * argv[]) {
int s;
s = sum(3,5);
printf("The integer is: %d\n",s);
return 0;
}
你的主文件中没有声明为 sum
所以它不知道如何正确调用它。
这个声明应该放在你的头文件中。
#ifndef heap_sort_h
#define heap_sort_h
int sum(int a, int b);
#endif /* heap_sort_h */