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

StackOverflow https://stackoverflow.com/questions/3483276

  •  28-09-2019
  •  | 
  •  

Question

#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[][];
}
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top