2011-11-09 7 views
0
int *column_to_row(int **a, int rows, int column_index) 
{ 
// a is a the matrix,rows are the number of rows in the matrix 
//column_index is the chosen column of the matrix to be turned into a vector 
    int i; 
    int *b=malloc(rows*sizeof(int));// b will be my returned vector 
    if(b==NULL) 
    { 
      exit(EXIT_FAILURE); 
    }  
    for(i=0;i<rows;i++) 
    { 
      b[i]=a[i][column_index]; 
    } 
    return b; 
} 

私はこのC2040エラーを得続ける:Cで行列の列を単一のベクトルにする適切な方法は何ですか?

error C2040: 'column_to_row' : 'int *(int **,int,int,int)' differs in levels of indirection from 'int()'

私が間違って何をしているのですか?

+0

する必要があります原因関数呼び出しが宣言と一致しないようにあなたは、この関数を呼び出すコードを表示することができます見えますか? – MByD

+1

コード自体に何も(構文的に)間違っています。関数が宣言される前に関数を呼び出そうとしていますか(つまり、同じコンパイル単位/ファイルで上位にあります)? – themel

+4

あなたのエラーは、あなたがcolumn_to_rowを呼び出す行に4つのパラメータが渡されていることを示しています。実際の通話を表示できますか?機能コード自体は上手く見えます。 –

答えて

1

この機能は正しく機能します。

プロトタイプが不足している可能性が高いと主張します。

int *(int **,int,int,int)は、それがint*(int **, int ,int)

関連する問題