C ++ While循环不会重复

时间:2016-10-11 20:29:30

标签: c++

我试图让我的程序中的WHILE循环重复。我现在已经在这里待了大约4个小时,所以也许我只是错过了一些东西。

无论我输入什么内容,我都无法重复循环。此外,如果我在提示符中输入多个字符,那么它会跳过我后续循环中的所有7个字符。

然后,更好的是,当输入内容时,最后的变量甚至不会改变,希望你可以帮助我解决上面列出的所有问题(越简单越好)。但是我现在只拿一个。

    cout << "Welcome. Input anything to start the sales reporting process.\n\n";
cin >> start; **//If I enter more than one character here it skips my other loops**
if (start == start)
{
    cout << "\n\nPlease enter the amount of each sale for Darwin when prompted, only enter one at a time.\n";
    cout << "When you are finished entering sales, input a '1'.\n\n";
    cout << "Enter a sale for Darwin: ";
    cin >> darwinSale;
    cout << endl << endl;
    while(darwinSale =! 1)
    {
        cout << "Enter a sale for Darwin: ";
        cin >> darwinSale;
        if (darwinSale <= 50999)
            darwinCom = darwinSale * 0.04;
        if (darwinSale >= 51000 and darwinSale <= 125999)
            darwinCom = darwinSale * 0.05;
        if (darwinSale >= 126000 and darwinSale <= 200999)
            darwinCom = darwinSale * 0.06;
        if (darwinSale >= 201000)
            darwinCom = darwinSale * 0.07;
        darwinComTotal = darwinComTotal + darwinCom;
        darwinTotal = darwinSale + darwinTotal;
        cout << endl << endl;
    }

1 个答案:

答案 0 :(得分:8)

在你的状态下,你实际上正在检查:

$this->session->set_userdata('your_msg_number_variable_name', msg_number)

并且!1检查1 == NULL是否返回0

您应该执行以下操作:

while(drawinSale = !1)