我知道这个问题有很多例子,但我无法弄清楚。这是一个非常简单的问题,但我把头发拉过来。起初我以为这就是我编写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;
}
...
答案 0 :(得分:4)
这是for
循环的格式而不是while
循环。您需要以下内容:
for(i = 0; i < CHAR_NUM; i++) //This is the line with the error
{
charCounts[i] = 0;
}
答案 1 :(得分:0)
将该行while
替换为for
。