SFML错误中的字符串输入

时间:2018-12-12 05:25:48

标签: c++ sfml

因此,我想创建一个循环,在该循环中输入一个字符串(以便以后可以在屏幕上从该字符串中绘制文本)该命令不是“ q”,因此我们继续输入字符串。每次输入字符串时,都会打开一个新的SFML窗口。

但是,这似乎是一个带有“下溢”错误的无限循环。我想知道您能否在代码逻辑方面为我提供帮助。非常感谢!

int main(){ 
    char command;
    cout << "Enter command: [S]tart     [Q]uit" << endl;
    cin >> command;

    // Get the string input
    while (command != 'q'){
        cout << "Enter string: ";
        string s;
        cin.ignore(numeric_limits<streamsize>::max(), '\n');
        getline (cin, s);
        cout << "The string is: " << s << endl;


        // Set up the window
        window.create(sf::VideoMode(1500, 1500), "SFML works");
        while (window.isOpen()){
            sf::Event event;

            while (window.pollEvent(event)){
                switch (event.type){
                    case sf::Event::Closed:
                        window.close();

                        break;
                }
            }
            window.clear();
            window.display();

        }
        cout << "Enter command: [C]ontinue     [Q]uit" << endl;
        cin >> command;
    }
}

0 个答案:

没有答案