C 背包分公司;绑定奇怪的编译错误

C 背包分公司;绑定奇怪的编译错误,c,algorithm,compilation,compiler-errors,knapsack-problem,C,Algorithm,Compilation,Compiler Errors,Knapsack Problem,因此,我正在使用分枝定界算法来实现背包问题。我已经完成了它的实现,但是我遇到了一些奇怪的编译错误,我不知道如何修复这些错误: 编译错误 gcc -Wall -pedantic -g -std=c99 -c -o bnb.o bnb.c bnb.c: In function ‘branch_and_bound’: bnb.c:225: warning: cast from pointer to integer of different size bnb.c:229: warning: impl

因此,我正在使用分枝定界算法来实现背包问题。我已经完成了它的实现,但是我遇到了一些奇怪的编译错误,我不知道如何修复这些错误:

编译错误

gcc -Wall -pedantic -g -std=c99   -c -o bnb.o bnb.c
bnb.c: In function ‘branch_and_bound’:
bnb.c:225: warning: cast from pointer to integer of different size
bnb.c:229: warning: implicit declaration of function ‘copy_string’
bnb.c:248: warning: cast from pointer to integer of different size
bnb.c:251: error: ‘struc_sol’ has no member named ‘string’
bnb.c:260: error: ‘struc_sol’ has no member named ‘string’
bnb.c:260: warning: cast from pointer to integer of different size
bnb.c:263: error: ‘struc_sol’ has no member named ‘string’
make: *** [bnb.o] Error 1
对我做错了什么有什么建议吗

bnb.c:225:警告:从指针强制转换为不同大小的整数

这是一行:

     topNode->solution_vec[i] = (int)malloc(sizeof(int));
正如消息所提到的,
malloc()
返回一个指针。你不应该把它转换成整数。实际上,您根本不需要为
solution\u vec[i]
分配内存,因为它已经由
topNode
的早期分配分配分配了


bnb.c:229:警告:函数“copy_string”的隐式声明

检查头文件中是否声明了
copy\u string()


bnb.c:251:错误:“struc_sol”没有名为“string”的成员


正如前面提到的,
struc\u sol
没有名为
string
的成员,因此
child1Node->string
会导致语法错误。

您不理解哪个错误消息?请提供一个最小的示例。我不想浏览300多行代码。谷歌对每个错误的简短搜索应该会让你对问题所在以及需要解决的问题有一个大致的了解。如果您在理解某个特定错误时遇到问题,请删除部分代码,直到只剩下该错误,然后将其发布到问题中。