简体   繁体   中英

bug-input 2d array using scanf in C

Whats wrong with this?I am getting segmentation fault during runtime.

int size;
scanf("%d",&size);
int init[size][size];
 //initial matrix
for(int i=0;i<size;i++)
  for(int j=0;j<size;j++)
     scanf("%d",init[i][j]);

您需要&init[i][j]而不是scanf() init[i][j]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM