Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22063

Inputting a space seperated 2-D array

$
0
0

I was recently working on 2-D arrays in C. My code looks something like this -

#include<stdio.h>void main(){    int A[3][3];    int i,j;    for(i=0;i<3;i++)    {        for(j=0;j<3;j++)            scanf("%d",&A[i][j]);    }    for(i=0;i<3;i++)    {        for(j=0;j<3;j++)            printf("%d ",A[i][j]);        printf("\n");    }}

The input I gave was -

2 1 3

1 3 2

1 2 3

But I don't know why the C(GCC 6.3) compiler tends to throw a run-time error. The code seems to work fine and matrix A shows everything perfectly while display.


Viewing all articles
Browse latest Browse all 22063

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>