How to scanf to just one dimension of a multidimensional array in C? -
suppose have c code this, declares small multidimensional array:
#include <stdio.h> #include <conio.h> int main(void) { int mat[5][2] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } scanf("%i", &mat[][]); while (getchar() != '\n'); return 0; }
and want change do scanf("%i", &mat[][]);
, , possibly line below it, allow me read user-supplied integers 2nd column of 5-by-2 multidimensional array.
i trying find simplest possible solution, without concern software security , without unnecessarily calling libraries.
you want this.
int i=0; do{ scanf("%d", &mat[i][1]); i++; }while (getchar() != '\n');
Comments
Post a Comment