1

I dont understand how this is implicit I return an int in every function and all of them are before the main function. Honestly first time seeing this someone send me a long code to debug and there were alot of mistakes but why isnt this working what am I missing

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;
}

Here is one of the functions

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;
}
hohenpaid
  • 99
  • 9

1 Answers1

5

It's not enough that the other functions come before the main function. Each function must appear before it's used in any other function. You probably have findString defined before the other 4 functions which would explain the warning.

Either reorder the functions so that they're defined before they're used elsewhere, or declare the functions at the top of the source file so the relative ordering doesn't matter.

dbush
  • 205,898
  • 23
  • 218
  • 273