c++ - 在 C++ 中调试程序时出现空白屏幕

标签 c++ visual-studio debugging visual-studio-2012

现在(编辑代码后)发生的事情是,每当我输入多个单词时,它就会出现痉挛。任何修复?谢谢。对不起,如果我看起来我什么都不知道。昂贵的书籍和没有人教我让我在线阅读教程。 (编辑后的代码如下。)

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

string qu;

int y;

int main()
{
y = 1;
while (y == 1)
{
    cout << "Welcome to the magic 8-ball application." <<"\nAsk a yes or no question, and the 8-ball will answer." << "\n";
    cin >> qu;
    cout << "\nProccessing...\nProccessing...\nProccessing...";
    cout << "The answer is...: ";
    int ans = (int)(rand() % 6) + 1;
    if (ans == 1)
        cout << "Probably not.";
    if (ans == 2)
        cout << "There's a chance.";
    if (ans == 3)
        cout << "I don't think so.";
    if (ans == 4)
        cout << "Totally!";
    if (ans == 5)
        cout << "Not a chance!";
    if (ans == 6)
        cout << "75% chance.";
    system("CLS");
    cout << "\nWant me to answer another question?" << "(1 = yes, 2 = no.)";
    cin >> y;
    }

return 0;

}

最佳答案

 while (y = 1);

应该是

 while (y == 1)

你有额外的 ; 并且应该使用 ==

关于c++ - 在 C++ 中调试程序时出现空白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16876543/

相关文章:

c++ - std::in_place_t 和 C++17 中的 friend

c++ - 如果基类有两个同名函数,则找不到基类函数

c++ - 为什么本地 .NET 程序集在我每次构建时(几乎)在引用列表中都出现损坏?

visual-studio - "Compare with Workspace version"和 "Compare with Latest version"和有什么区别?

c - 简化c中的多个整数

c++ - Qt QDockWidget 增加了额外的边距空间

javascript - 使用 Chutzpah 和 requirejs 测试 javascript

java - 在 IntelliJ Idea 中调试时在 Map 中设置值

#ifdef DEBUG 的 Python 等效项

java - 全局变量重置为0