Thread: Compiling Warning

  1. #1
    Registered User
    Join Date
    Jun 2011
    Location
    Haifa, Israel, Israel
    Posts
    7

    Compiling Warning

    Can someone please help me? When I compile the code, the line where I call the function gives me a warning, saying: 'Passing argument 1 from incompatible pointer type.' I have no idea how to fix it!!

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <math.h>
    
    
    #define N 3
    
    
    
    int find_inner_product (int *a,int *b,int size)
    	
    {int inner_product=0,i=0;
    	for (i=0;i<size;i++)
    		
    		{inner_product+=*(a+i)*(*b+i);}
    		
    	return inner_product;} /*function to do the inner product*/
    
    int i=0,j=0,row_number,column,inner_product;
    
    int main()
    {
    	int matrix1[N][N],matrix2[N][N];
    	
    	
    	printf("Please enter the values of the 3x3 Matrix: ");
    	
    	for	( i = 0; i < N; i++ ) 
    		{for( j = 0;  j< N; j++ )
    		
    		{scanf("%d", &matrix1[i][j]);}
    		} /*this for loop goes through every number and stores it in the first matrix*/
    	
    	
    	printf("\nPlease enter the values of the second 3x3 Matrix: ");
    	
    	for	( i = 0; i < N; i++ ) 
    		{for( j = 0;  j< N; j++ )
    		
    		{scanf("%d", &matrix2[i][j]);}
    		} /*this for loop goes through every number and stores it in the second matrix*/
    
    	
    	find_inner_product(matrix1, matrix2, N)
    	printf("%d", inner_product);
    	
    	
    }
    
    
    }

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <math.h>
    
    
    #define N 3
    
    
    
    int find_inner_product (int *a,int *b,int size)
    	
    {int inner_product=0,i=0;
    	for (i=0;i<size;i++)
    		
    		{inner_product+=*(a+i)*(*b+i);}
    		
    	return inner_product;} /*function to do the inner product*/
    
    int i=0,j=0,row_number,column,inner_product;    <---- move this inside main
    int main()           <--- the correct form is ... int main (void)
    {
    	int matrix1[N][N],matrix2[N][N];
    	
    	
    	printf("Please enter the values of the 3x3 Matrix: ");
    	
    	for	( i = 0; i < N; i++ ) 
    		{for( j = 0;  j< N; j++ )
    		
    		{scanf("%d", &matrix1[i][j]);}
    		} /*this for loop goes through every number and stores it in the first matrix*/
    	
    	
    	printf("\nPlease enter the values of the second 3x3 Matrix: ");
    	
    	for	( i = 0; i < N; i++ ) 
    		{for( j = 0;  j< N; j++ )
    		
    		{scanf("%d", &matrix2[i][j]);}
    		} /*this for loop goes through every number and stores it in the second matrix*/
    
    	
    	inner_product = find_inner_product(matrix1, matrix2, N); 	
                 printf("%d", inner_product);
    	
    	return 0;   <--- main always returns an integer value 
    }
    
    
    }
    [/QUOTE]

  3. #3
    Registered User
    Join Date
    Jun 2011
    Location
    Haifa, Israel, Israel
    Posts
    7
    Im still not getting the answer I should be. I need the dot product of the first line of the matrix and its not correct with my current code

  4. #4
    Registered User
    Join Date
    Jun 2011
    Location
    Haifa, Israel, Israel
    Posts
    7
    Nevermind, problem solved

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 03-12-2011, 06:59 PM
  2. Warning messages compiling C program
    By puth in forum C Programming
    Replies: 12
    Last Post: 09-09-2010, 08:57 AM
  3. Replies: 9
    Last Post: 05-28-2010, 10:11 AM
  4. warning
    By pe4enka in forum C Programming
    Replies: 2
    Last Post: 05-03-2010, 08:35 AM
  5. Compiling warning..
    By Jez_Master in forum C++ Programming
    Replies: 2
    Last Post: 05-01-2002, 10:45 PM

Tags for this Thread