开发者

i cant call my multidimensional array function from my main function. what is wrong with my parameters? declarations? variables? etc [closed]

开发者_如何学运维 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.
#include<stdio.h>
#include<string.h>

#define MAX_VAL 100

//Function declaration
int input_values(int Z[][k], int j, int k);


int main(void)
{
 int A(int [ ][k], int, int);
 int m, n;
 char comm[100];

 while(1){
  printf("\n>>");
  gets(comm);


   if(strcmp(comm,"MAKE A")== 0)
    input_values(A, j, k  );
  }  



}
//make or overwrite matrix
int input_values(int Z[][k], int j, int k)
{
 int row, col;

 //DETERMINING THE SIZE OF MATRIX
  do{
   printf("Enter the number of rows: ");
   scanf("%d", &row);
    if(row>100)
     printf("Size is out of bounds! Size must be less than or equal to 100\n");
  }while(row>100);        
  do{
   printf("Enter the number of columns: ");
   scanf("%d", &col);
    if(col>100)
     printf("Size is out of bounds! Size must be less than or equal to 100\n");
  }while(col>100); 

 //ENTERING THE VALUES OF MATRIX
  for(j=0; j<row; j++)                                                                          
   for(k=0; k<col; k++){
    printf("A[%d][%d] = ", j, k);
    scanf("%d", &Z[j][k]);
    }

return Z[][];
}


Well, int Z[][k] isn't valid syntax in C. Not as a declaration and not as a parameter. And it certainly isn't C#.

Furthermore, int A(int [ ][k], int, int); is a forward declaration for a function. It is not a match for the 1st parameter of input_values.

I'm guessing you ended up with this notation for A because it gives no syntax errors. That is because the C compiler just ignores the invalid k in there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜