Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C Beginner Errors arrays
I am writing a program related to Graph Theory, I wrote code for matrix multiplication by using functions, that worked well. when I am using that function into this program I am getting following errors.
 
I don't understand why this is happening?
 
Here I am giving you the part of code from my whole program.
float product(int,int,int,int,float a[20][20],float b[20][20],float c[20][20]);
/*first to integers order of matrix a &
 second two integers are order of matrix b
 and float c is result of a*b */
 
float yn[ar][ar],temp[ar][ac];
product(ar,ac,ac,ac,incidence,yb,temp);/*calling function*/
 

float product(int ar,int ac,int br,int bc,float a[20][20],float b[20][20],float c[20][20])
{   int i,j,k;
  if(ac==br)
  {
    for(i=0;i<ar;i++)
    {
      for(j=0;j<bc;j++)
      {
        c[i][j]=0;
        for(k=0;k<ac;k++)
        {
          c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
        }
      }
      printf("\n");
    }
  }
  else
  {
    printf("Please Enter proper matrices");
    return -1;
  }
  return 0;
}
When I run this, I am getting these errors.
prog.c: In function ‘main’:
prog.c:40: warning: passing argument 5 of ‘product’ from incompatible pointer type
prog.c:4: note: expected ‘float (*)[20]’ but argument is of type ‘int (*)[(unsigned int)(ac)]’
prog.c:40: warning: passing argument 6 of ‘product’ from incompatible pointer type
prog.c:4: note: expected ‘float (*)[20]’ but argument is of type ‘int (*)[(unsigned int)(ac)]’
Posted 13-Oct-12 7:11am
N Shiva526
Edited 13-Oct-12 7:37am
v4

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I have solved this problem my self. What I did is...
 
I have given float as inputs but
I am calling the function for int arrays.
that is the problem.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 Jochen Arndt 180
4 DamithSL 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 13 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100