c - 错误 : expected ')' before ';' token

标签 c for-loop compiler-errors

我知道这个问题有很多例子,但我想不通。这是一个非常简单的问题,但我正在努力解决它。起初我以为这是我编写 for 循环的方式,但在重写它并从另一个编译的文件中复制它之后,我仍然有问题。我查看了前面几行,但找不到任何打开的 {[(。我换出了 CHAR_NUM 257 但仍然没有骰子。问这个我感觉很不好,因为我知道这会很愚蠢,但我想不通。

这里是错误:

35: error: expected ')' before ';' token

错误代码如下:

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include "tree.h"

#define CHAR_NUM 257

void countChars(int *, FILE *);
void makeTrees(int *, struct tree *);
struct tree *makeQueue(struct tree *);
int arrayFilled(struct tree *);
void findSmallest(struct tree *, struct tree *, struct tree *);

int main (int argc, char **argv)
{
    assert(argc == 3);
    int *charCounts, *bitList;
    FILE *big, *small;
    struct tree *charList, *heap;
    int i;

    assert((charCounts = malloc(sizeof(int) * CHAR_NUM)) != NULL);
    assert((charList = malloc(sizeof(struct tree) * CHAR_NUM)) != NULL);
    assert((big = fopen(argv[1], "r")) != NULL);
    assert((small = fopen(argv[2], "wb")) != NULL);

    while (i = 0; i < CHAR_NUM; i++) //This is the line with the error
    {
        charCounts[i] = 0;
    }
...

最佳答案

这是 for 循环的格式,而不是 while 循环的格式。您想要以下内容:

for(i = 0; i < CHAR_NUM; i++) //This is the line with the error
{
    charCounts[i] = 0;
}

关于c - 错误 : expected ')' before ';' token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23961823/

相关文章:

cudaMemcpy 无法复制值

python - 在for循环中递归运行for循环(python)

用于循环变量扩展的 Windows 批处理脚本不起作用

c++ - 不一致的字符串流错误

c++ - 智能感知 : cannot open source file "curl.h" in C++

c++ - 如何在C++中正确使用#ifndef#define #endif

c - 如何使用 snprint() 函数追加字符串

c - 链表 — 删除包含素数的节点

C,段错误(核心转储),Linux。我能做些什么?

java - 在 Java 中跳过 For 循环中的迭代