-C中的Wimplicit函数声明



我不明白这是如何隐含的——我在每个函数中都返回一个int,并且所有函数都在主函数之前。老实说,第一次看到这个,有人给我发了一个很长的代码来调试,有很多错误,但为什么不起作用呢?我错过了

int findString(char matrix[ROW][COLUNM],char str1[],int length){
int left,right,top,down,result;

left=left2_right(matrix,str1,length);-THESE 4 CALLS GIVE THE WARNINGS
right=rigth2_left(matrix,str1,length);
top=top_bottom(matrix,str1,length);
down=bottom_top(matrix,str1,length);
if(left != -1 ){result=left;}
if(right != -1 ){result=right;}
if(top != -1 ){result=top;}
if(down != -1 ){result=down;}
return result;
}

这是的一个功能

int left2_right(char matrix[ROW][COLUNM],char str1[],int length){
int i = 0, j, counting = 0, wordcnt;
//int length = computeLength(str1);   //returns legth of string   
int index = -1;
for (i = 0; i < ROW; i++)
{
for (j = 0; j < COLUNM; j += 1)
{
if (matrix[i][j] == str1[0])
{    counting = 0;
for (wordcnt = 0; wordcnt < length; wordcnt++)
{
if (matrix[i][j + wordcnt] == str1[wordcnt])
{
counting++;
}
}
if (counting == length)
{
index = (i *12) + j;
}
}
}
}
return index;
}

其他函数位于main函数之前是不够的。每个函数在用于任何其他函数之前都必须出现。您可能在解释警告的其他4个函数之前定义了findString

要么对函数进行重新排序,以便在其他地方使用之前对其进行定义,要么在源文件顶部声明函数,这样相对顺序就无关紧要了。

最新更新