scanf( "%d", &ar[rows][cols] );
ユーザーが int 変数に入力した値を取得しようとしていますtemp
。
しかし、どういうわけか実行すると、直後にエラーが発生しますprintf( "Please enter 9 positive integers : " );
編集:コードを含めるのを忘れていました。コードは次のとおりです。
/* File: StudentID_Surname.c - e.g. 1234567_Wilson.c
* This program finds the range between highest and lowest value of a 2-D array */
#include <stdio.h>
#define NROW 3
#define NCOL 3
/* Write a function
void disp_arr(int a[NROW][NCOL]) { ... }
where a[][] is the 2-D array
Print the entire array to the screen. */
disp_arr( temp );
int main(void)
{
/* declare needed variables or constants, e.g. */
int ar[NROW][NCOL];
int rows, cols, temp;
/* prompt for the user to enter nine positive integers to be stored into the array */
for ( rows = 0 ; rows < 3 ; rows++ )
{
for ( cols = 0 ; cols < 3 ; cols++ )
{
printf( "Please enter 9 positive integers : " );
scanf( "%d", &ar[rows][cols] );
temp = disp_arr(ar[rows][cols]);
printf( "%d\t", temp );
}
printf("\n");
}
}/* end main */
disp_arr( int temp )
{
int x,y;
int a[x][y];
printf( "%d", a[x][y] );
return a[x][y];
}
私の間違いはどこですか?