Codeblocks 20.3和minGW_x64_Win_Build之间有什么错误?

问题描述

我在执行过程中遇到以下错误。我正在使用的编译器是minGW_x64_Win_Build。位置,目录和所有内容均处于正确状态。 不知道,但这是内部错误。

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
F:\CodeBlocks Training\Completed Programs\Calculator 0.cpp|38|fatal error: x64: No such file or directory|
|| === Build failed: 1 error(s),0 warning(s) (0 minute(s),0 second(s)) ===|

代码:

#include <iostream>
using namespace std;

void MainMenu();
void Decision(double,double);

int main()
{
    MainMenu();
    double userInput1;
    double userInput2;
    cout << " Enter Your Choice: " << '\n';
    cin >> userInput1;
    cout << " Enter Your Second Choice: " << '\n';
    cin >> userInput2;
    Decision(userInput2,userInput2);
    return 0;
}
void MainMenu()
{
    cout << " Enter Your choice" << '\n';
    cout << " -----------------" << '\n';
    cout << " 1 for Addition" << '\n';
    cout << " 2 for Subtraction" << '\n';
    cout << " 3 for Multiplication" << '\n';
    cout << " 4 for Division" << '\n';
    cout << " -----------------" <<'\n';
}
void Decision(double userInput1,double userInput2)
{
    int R_usr;
    switch (R_usr)
    {
    case 1:
        cout << " The Result for the entered values: " << userInput1 << " and " << userInput2 << " is equal to: (" << userInput1 + userInput2 << ")" <<'\n';
        break;
    }
}

快照

enter image description here

COMPILER

enter image description here

解决方法

问题已解决。

从20.3降级为代码块17.12

工作正常:

#include <iostream>
#include <limits>
using namespace std;

void optionManue();
void userDecision_(int);

double resultAddition(double,double);
double resultSubtraction(double,double);
double resultMultiplication(double,double);
double resultDivision(double,double);
bool isvalid_(string);

int main()
{
    int userChoice_;
    char restart_;
    do{
    system("cls");
    optionManue();
    cout<< " Enter the Choice: ";
    while (!(cin>>userChoice_))
    {
        system("cls");
        cin.clear();
        cin.ignore(numeric_limits<streamsize>:: max(),'\n');
        system("cls");
        cout<< " Wrong choice detected! Illegal stance stopped! Try again." << '\n';
        cout<< " *********************************************************" << '\n';
        optionManue();
        cout<< " Enter the Choice: ";
    }
    userDecision_(userChoice_);
    do{
        cin.clear();
        cout << " Do you want to Restart the App? [Y/n] " ;
        cin >> restart_;
        system("cls");
        optionManue();
        cin.ignore(numeric_limits<streamsize>::max(),'\n');

        }while (restart_!='Y'&&restart_!='y'&&restart_!='N'&&restart_!='n');
    }while (restart_ == 'Y' || restart_ == 'y');
    return 0;
}
void optionManue()
{
    cout << " -----------------------------------------------------------" << '\n';
    cout << " Select the option by Following Numbers that you want to use" << '\n';
    cout << " -----------------------------------------------------------" << '\n';
    cout << " 1 for + Addition " << '\n';
    cout << " 2 for - Subtraction " << '\n';
    cout << " 3 for * Multiplication " << '\n';
    cout << " 4 for / Division " << '\n';
    cout << " --------------------------------------------------" << '\n';
}
void userDecision_(int userChoice_)
{
    double
    userValueAdd_1,userValueAdd_2,userValueSub_1,userValueSub_2,userValueMul_1,userValueMul_2,userValueDiv_1,userValueDiv_2;
    switch(userChoice_)
    {
    case 1:do{cout<< " Enter the values for Addition"<<'\n'; cout << " First Value: ";cin>>userValueAdd_1;cout<< " Second Value: ";cin>> userValueAdd_2;}while(!isvalid_("Ops! Entered invalid value,Try again."));
    resultAddition(userValueAdd_1,userValueAdd_2);
    break;
    case 2:do{cout<< " Enter the values for Subtraction"<<'\n'; cout << " First Value: ";cin>>userValueSub_1;cout<< " Second Value: ";cin>> userValueSub_2;}while(!isvalid_("Ops! Entered invalid value,Try again."));
    resultSubtraction(userValueSub_1,userValueSub_2);
    break;
    case 3:do{cout<< " Enter the values for Multiplication"<<'\n'; cout << " First Value: ";cin>>userValueMul_1;cout<< " Second Value: ";cin>> userValueMul_2;}while(!isvalid_("Ops! Entered invalid value,Try again."));
    resultMultiplication(userValueMul_1,userValueMul_2);
    break;
    case 4:do{cout<< " Enter the values for Division"<<'\n'; cout << " First Value: ";cin>>userValueDiv_1;cout<< " Second Value: ";cin>> userValueDiv_2;}while(!isvalid_("Ops! Entered invalid value,Try again."));
    resultDivision(userValueDiv_1,userValueDiv_2);
    break;
    default:
        cout<<" Not allowed input! Try again with legal or allowed characters or Escape." << '\n';
    }
}
double resultAddition(double userValueAdd_1,double userValueAdd_2)
{
    double ResultAd = userValueAdd_1 + userValueAdd_2;
    cout<< " The addition of " << userValueAdd_1 << " and " << userValueAdd_2 << " is = " << ResultAd << '\n';
}
double resultSubtraction(double userValueSub_1,double userValueSub_2)
{
    double Resultsub = userValueSub_1 - userValueSub_2;
    cout<< " The addition of " << userValueSub_1 << " and " << userValueSub_2 << " is = " << Resultsub << '\n';
}
double resultMultiplication(double userValueMul_1,double userValueMul_2)
{
    double Resultmul = userValueMul_1 * userValueMul_2;
    cout<< " The addition of " << userValueMul_1 << " and " << userValueMul_2 << " is = " << Resultmul << '\n';
}
double resultDivision(double userValueDiv_1,double userValueDiv_2)
{
    double Resultdiv = userValueDiv_1 / userValueDiv_2;
    cout<< " The addition of " << userValueDiv_1 << " and " << userValueDiv_2 << " is = " << Resultdiv << '\n';
}

bool isvalid_(string err_msg)
{
    if(cin.rdstate())
    {
        cin.clear();
        cin.ignore(numeric_limits<streamsize>:: max(),'\n');
        system("cls");
        optionManue();
        return false;
    }
    return true;
}
,

您的switch语句检查一个未初始化的变量。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...