小编Gol*_*TMM的帖子

为什么在语言C的嵌套for循环中跳过scanf()?

我正在为类编写一个程序,要求用户输入二维数组的大小,然后让用户输入数组的值.这是我到目前为止的代码:

#include <stdio.h>

int main(void)
{
    // Setup 
    int N, M;
    int row = 0, col = 0;

    printf("\n");
    printf("This program counts occurences of digits 0 through 9 in an NxM array.\n");
    printf("Enter the size of the array (Row Column): ");
    scanf(" %d %d", &N, &M);

    int array[N][M];     

    // Array Input
    for (row = 0; row < N; row++)
    {    
        printf("Enter row %d: ", row);      
        for (col = 0; col < M; col++); 
        {    
            scanf(" %d", &array[row][col]);
        }   
    }    
    printf("\n"); …
Run Code Online (Sandbox Code Playgroud)

c for-loop scanf

2
推荐指数
1
解决办法
48
查看次数

标签 统计

c ×1

for-loop ×1

scanf ×1