Search
 
SCRIPT & CODE EXAMPLE
 

C

how to scanf two dimensional array in c

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char* arv[]){

  int target;               // for later processing, irrelevant here
  int m;                    // m = #rows and #columns of array
  int array[m][m];
  scanf("%d %d", &target, &m);
 
  int i, k;
  for(i = 0; i < m; i++){
    for(k = 0; k < m; k++){
       scanf("%d", &(array[i][k]));    // save value in array.
    }
  }
                                      // the problem occurs before this point.
  for(i = 0; i < m; i++){
     for(k = 0; k < m; k++){
       printf("%2d", array[i][k]);    // print array.
     }
     printf("
");
  }  

  return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: PATH_MAX 
C :: bitwise operators in c 
C :: accessing elements of 1d array using pointers 
C :: go Iterating over an array using a range operator 
C :: gcc options to find out makefiel rules 
C :: c to llvm 
C :: Convert mpg / mp4 to gif with ffmpeg 
C :: arduino wifi client 
C :: fopen in c example 
C :: geom boxplot remove outliers 
C :: The fscanf and fprintf functions 
C :: equal string c 
C :: HOW TO ADD FORM IN BOOTSTRAp 
C :: flip exis in dataframe 
C :: syntax 
C :: identifiers in c 
C :: array of strings in c 
C :: malloc c 
C :: how to run c program from visual studio terminal 
C :: Turn on the first n Bits in number 
C :: c extern 
C :: insert image material ui 
C :: c unused parameter 
C :: mc dropout pytorch 
C :: use frama c online 
C :: fine print serial key 
C :: cocktail sort in c 
C :: block quote in lua 
C :: C access global variable same name 
C :: int main() { int sum =0; FILE * ptr; ptr = fopen("d:students. "," "); if (ptr ==NULL){ ("file does not exist!!"); exit(0); } 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =