简体   繁体   English

有人能告诉我为什么这个程序总是崩溃吗?

[英]Can someone tell me why this program keeps crashing?

Maybe I'm still tired, but I can't seem to figure out why this keeps crashing after the second input.也许我仍然很累,但我似乎无法弄清楚为什么在第二次输入后会一直崩溃。 No point in sorting it if it keeps breaking before the values are entered.如果它在输入值之前一直中断,则对其进行排序毫无意义。

#include <stdio.h>

#define MAX 5

int main(){

  int input[MAX], output[MAX], i, j, high;

  printf("Please enter 5 exam scores.\n");
  for (i=0; i<MAX; i++){
      scanf("%d\n", input[i]);
  }
  for(i=0; i<MAX; i++)
      printf("%d\n", input[i]);

  return 0;
}

The problem is occurring because you forgot to put '&' before input[i]:出现问题是因为您忘记在 input[i] 之前放置 '&':

scanf("%d\n", input[i]);
///          ^    missing &

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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