for循环中pow()的编译器错误

0 c double for-loop casting

我正在编写一个函数来打印出C中的三元树.当然,我的方法非常低效,但是除此之外,我需要做的就是打印树而不考虑空间或时间复杂度.

编译器(gcc)在for循环所在的行上给出了一个错误.我无法弄清楚出了什么问题.我甚至将空为空,我已经包含了math.h,所以我真的不知道问题是什么.请帮忙!

这是编译器的输出:

make traverse clean gcc -c -Wall tr​​aversals.c
traversals.c:在函数'printTree'中:
traversals.c:112:错误:')之前的语法错误'token
traversals.c:112:错误:')之前的语法错误令牌
:* [traversals.o]错误1

遗憾的是,它实际上并没有具体说明错误.我认为实际上有2个错误.

void printTree(node_t* node)
{
    printf("%d %s %d\n", node->depth, node->string, node->counter); // Print the root node
    int level;
    double empty = 0;
    // Starting from the second level and ending when all the children of a particular level are null
    for(level = 2; empty != pow(3, level - 1)); level++)
    {
        empty = checkLevel(node, level); // Print out any children that match the requested depth level and return the number of empty children
    }
}
Run Code Online (Sandbox Code Playgroud)

cni*_*tar 8

你有额外的 )

for(level = 2; empty != pow(3, level - 1)); level++)
                                         ^ here
Run Code Online (Sandbox Code Playgroud)