我在以下问题上打了几个小时:我粘贴了2个功能,但还有更多功能.我在我的程序上运行valgrind,我得到32个类似于此的错误:
==4214== 6 errors in context 8 of 10:
==4214== Conditional jump or move depends on uninitialised value(s)
==4214== at 0x40088F: getNextFreeCell (in /a/fr-01/vol/home/stud/ashers03/c/ex4/test)
==4214== by 0x400C7A: InsertObject (in /a/fr-01/vol/home/stud/ashers03/c/ex4/test)
==4214== by 0x401137: main (in /a/fr-01/vol/home/stud/ashers03/c/ex4/test)
Run Code Online (Sandbox Code Playgroud)
我在其他功能上遇到更多错误,但是同样的错误.我无法理解为什么它没有被初始化.谢谢大家的帮助.
这是主要功能:
int main(int argc, char* argv[]) {
size_t tableSize = (size_t)atoi(*(argv+1));
TableP table = CreateTable(tableSize,IntFcn, IntPrint,IntCompare);
int i;
for (i=FIRST; i<=LAST; i++) {
int *key = (int*)malloc(sizeof(int));
*key = i;
ObjectP obj = CreateObject(key);
InsertObject(table,obj);
}
PrintTable(table);
FreeTable(table);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这些defs在头文件中:
typedef …Run Code Online (Sandbox Code Playgroud) 我需要编写一个函数来接收函数指针数组.我写了下面的代码,但是我现在在测试它时遇到了麻烦.
这是定义函数数组指针的正确方法吗?
typedef (*Function)(double);
void func(Function* arr);
Run Code Online (Sandbox Code Playgroud)
如果我想用[20]声明数组的大小,我写道:
void func(Function arr[20]);
Run Code Online (Sandbox Code Playgroud)
?
谢谢你的帮助
c ×2