//Program Written By: Andre Chitsaz-zadeh
//Program Written On: 10/7/12
//Program calculates book cost for multiple book orders. Program written using multiple functions.`

#include <stdio.h>
#define SIZE 5

void inputData();

int main ()


{
    inputData();
}

void inputData()

{
    int i = 0;
    int costs[5];
    printf( "\nPlease enter five products costs.\n" );
    while(i < 5)
    {
    scanf("%d", costs[i]);
    i = i + 1;
    }
}

为什么会出现异常错误?程序看起来很简单!它编译起来没有问题,但只要我输入一个数字,它就会说“这个程序已经停止工作”。谢谢!!

最佳答案

scanf("%d", costs[i]);

应该是:
scanf("%d", &costs[i]);// &cost[i] gets the address of the memory location you want to fill.

10-08 08:49