"Id returned 1 exit status"错误 C++

"Id returned 1 exit status" error c++

本文关键字:错误 C++ status Id returned exit      更新时间:2023-10-16

我正在写这个相当简单的代码,但突然我开始得到这个"Id返回1退出状态错误"。我对这段代码所做的最新更改是在显示函数中添加了所有的"endl"。我不知道该怎么办,请帮帮我。

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void getOrder(double&spools, double&stock, double&charge);
void displayOrder(double spools, double stock, double charge);

int main()
{
    double spools;
    double stock;
    double charge;
    getOrder(spools, stock, charge);
    displayOrder(spools, stock, charge);
    system("pause");//come back to these v2v lines
    return 0;   
}
void getOrder(double&spools, double&stock, double&charge)
{
    charge= 0;
    char extra;
    double extraCharge;
    cout<<"How many spools were ordered?:";
    cin>>spools;
    while(spools<1){
        cout<<"Entry must be greater than 1...: ";
        cin>> spools;
    }
    cout<<"How many spools are in stock?:";
    cin>>stock;
    while(stock<0){
        cout<<"Entry must be greater than 0...: ";
        cin>> stock;
    }
    cout<<"Are there any special shipping and handling chsrges?(y for yes, n for no):";
    cin>>extra;
    if(extra=='y'|| extra=='Y'){
        cout<<"Enter the special charge amount:$";
        cin>>extraCharge;
        while(extraCharge<0){
        cout<<"Entry must be greater than 0... :";
        cin>> extraCharge;
        }
    }
    charge=extraCharge;
//no returns needed because reference variables 
}
void displayOrder(double spools, double stock, double charge=10)
{
    double backOrder=spools-stock;
    double spoolsOrdered;
    double subTotal=spools*100;
    double shipping;
    double total=subTotal+charge;
    double ready=stock-spools;
    //spools ready to ship from current stock
    cout<<"There are"<<ready<<"spools ready to be shipped."<<endl;
    //if statement for BACKORDERRRrr
    if(spools>stock)
    {
        backOrder=spools-stock;
        cout<<"There are"<<ready<<"spools ready to be shipped."<<endl;
        cout<<"There are"<<backOrder<<"spools on back order."<<endl;
        cout<<"Subtotal: $"<<subTotal<<endl;
        cout<<"Shipping & Handling charge:$"<<charge<<endl;
        cout<<"The total fee for this transaction is:$"<<total<<endl;
    }
    else
    {
        cout<<"There are"<<ready<<"spools ready to be shipped."<<endl;
        cout<<"Subtotal: $"<<subTotal<<endl;
        cout<<"Shipping & Handling charge:$"<<charge<<endl;
        cout<<"The total fee for this transaction is:$"<<total<<endl;
    }
}

我刚刚在Dev c++上试过你的代码,它运行得很好。出现此错误的一个可能原因是以前运行的.exe文件在某个地方仍然处于ON状态。