-3

我正在创建一个程序来查找使用和充电的个人和总千瓦时,以及客户总数。我收到的错误消息是undefined reference to "If"什么Id returned 1 exit status 原因造成的?

 /* program to determine cost for a certain number of kilowatt hours */

#include <stdio.h> /* printf, scanf definitions */
#include <math.h>

double charges_to_return(int kwh_f);

int main (void)
{
    int cust_number;
    int kwh;
    int total_cust;
    int total_kwh;
    double total_charge;
    double cust_charge;
    double charge;

    total_cust = 0;
    total_kwh = 0;
    total_charge = 0;
    cust_number = 0;

    while (cust_number != -1)
    {   
        printf("Enter customer number and kwh (-1 to quit): ");
        scanf("%d %d", &cust_number, &kwh);

        If (cust_number != -1);
        {
            total_cust++;
            total_kwh = total_kwh + kwh;
            cust_charge = charges_to_return(kwh);
            total_charge = total_charge + cust_charge;

            printf("Customer Num: %d     KWH used: %d    Charge: %.2lf", cust_number, kwh, cust_charge);
        }
    }

    printf("Total Customers:  %d     Total KWH used:  %d        Total Charges:  %.2f", total_cust, total_kwh, total_charge);

    return (0);     
}
4

1 回答 1

1

您还没有尝试在谷歌上搜索错误消息,有没有...这是一个链接器错误,告诉您没有使用 name 定义的函数If。也许您想用if关键字编写分支语句... C 区分大小写。

旁注:修复此问题后,从 之后删除分号if,因为这是一个空语句。然后,缩进并格式化你的代码,因为它目前是一个无法阅读的一团糟。您的代码不仅有小问题,而且基础知识也有问题。

于 2013-07-04T23:42:56.183 回答