【发布时间】:2012-10-23 15:23:38
【问题描述】:
我正在尝试将一个包含字符串的二维数组传递给一个函数。我不断得到 ] 标记之前的预期表达式。
这段代码的重点是阅读一个单词搜索谜题,然后找到该谜题中的单词。我要写一个函数,用于向前搜索、反向搜索,然后是向上和向下搜索。
如何消除此错误?错误在我调用 forward 函数的最底部。
/*Andrea Hatfield CPE 101 October 31st, 2012*/
#include <stdio.h>
#include <string.h>
int forward(char words[][8], char puzzle[][11]);
int main()
{
char puzzle[11][11];
char words[8][8];
FILE *fin, *fwords;
int i = 0;
int j= 0;
fin = fopen("puzzle.in", "r");
fwords = fopen("words.in", "r");
if(fin == NULL) /*Reads in the puzzle file*/
printf("File does not exist");
else
{
while(fscanf(fin,"%s", puzzle[i])!=EOF)
{
printf("%s\n", puzzle[i]);
i++;
}
}
if(fwords == NULL) /*Reads in the words the puzzle will search for */
printf("File does not exist");
else
{
while(fscanf(fwords, "%s", words[j])!=EOF)
{
printf("%s\n", words[j]);
}
}
forward(&words[][8], &puzzle[][11]); /*Error at this point*/
return(0);
}
【问题讨论】:
-
欢迎来到 Stackoverflow,您能否提供一个明确的问题?