0

スキャン arr 機能の問題。

void scan_arr(double ar[3][5]) // Declares that it is a 3 x 5
{

    int x;
    int y;
    printf("Enter arrays of 3x5\n");

    for( x = 0; x < 3; x++ ) // Shows that this loop shall be done 3 times 
    {
        for( y = 0; y < 5; y++ ) // Shows that 5 times * the number of the first loop
        {
            scanf("%lf",ar[x][y]); // Scans @ x * y and terminates after first input
        }
    }
}
4

2 に答える 2

4

これは、 の前にアンパサンドがないためですar[x][y]:

scanf("%lf", &ar[x][y]);
//           ^
//           |
//          Here

scanf値が格納されるアイテムのアドレスが必要なため、「アドレスを取る」演算子を使用する必要があります&

于 2013-05-07T15:40:32.743 に答える
1

関数の配列の要素のアドレスを渡す必要があるscanfため、これを置き換えます。

scanf("%lf",ar[x][y]);

scanf("%lf", &ar[x][y]);
于 2013-05-07T15:41:23.787 に答える