よろしければ、エラーとなっている原因とどのように修正をすればよいか、また修正したものをお見せしていただけないでしょうか。
また、もし読みにくいと思いましたら好きなように変更しても構わないです。
使用コンパイラはborland社のものです。
エラー文
エラー E2034 test.cpp 35: 'int' 型は 'struct' 型に変換できない(関数 keisan(struct *,int) )
#include <stdio.h>
#include <stdlib.h>
/* 構造体宣言 */
typedef struct
{
int a;
double b;
}*test_t;
int keisan( test_t , int);
/* メイン */
int main()
{
test_t test;
int n;
/* 配列サイズの入力 */
printf( "n = " );
scanf( "%d", &n );
keisan( test , n );
free(test);
}
int keisan( test_t test , int n )
{
test = (test_t)calloc( n , sizeof(test_t) );
if(test == NULL) return 1;
for(int i = 0 ; i < n ; i++ )
{
test[ i ] = i * 10;
printf("test[%d] = %d", test[i] , i);
}
return 0;
}