강의

멘토링

커뮤니티

Inflearn Community Q&A

kskc4535561's profile image
kskc4535561

asked

Learning C language through problems

2D array output 1

42번 bus error;;;

Written on

·

606

0

#include<stdio.h> 
int a[11][11];
int main(){
    int i,j,n,k=0,temp;
    scanf("%d",&n);
    temp = n;
    for(i=0;i<n; i++){
        for(j=0;j<n;i++){
            a[i][j]= temp + 5*k;
        }
        temp--;
    }
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            printf("%3d",a[i][j]);
        }
    printf("\n");
    }
    return 0;
}

전 이렇게 쓰고 싶은데 이렇게 실행시키면 bus error
 가 뜹니다 이게 왜 틀린것이죠?
c

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

에러가 나는 이유는 오타입니다.

for(j=0;j<n;i++){
kskc4535561's profile image
kskc4535561

asked

Ask a question