Closed. This question is off-topic. It is not currently accepting answers. Learn more
想改进这个问题吗?Update the question所以堆栈溢出的值小于aa>。
5年前关闭。
编辑:哇。我在scanf函数中漏掉了“&”。不过,谢谢你的帮助。
我使用的是Code::Blocks,我试图构建一个简单的程序来提示用户输入10个数字,然后显示它们。问题是,它会打印问题,但一旦我键入一个数字,它就会崩溃,而不是用scanf()赋值……下面的代码。
main()
{
  int userNums[11] = {0};
  int x;
  char displayOrder = '\0';

  for (x = 0; x <= 10; x++)
  {
    printf("Enter a number: ");
    scanf("%d", userNums[x]); //code crashes here
  }
//code continues...

最佳答案

固定的:

scanf("%d", &userNums[x]); //code won't crash now

关于c - For循环在C中崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17910956/

10-12 12:20
查看更多