我正在尝试将用户输入的值从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];
}
我的错误在哪里?