小编Seb*_*era的帖子

循环调用该函数只需一次C++

我有这个代码的问题,我插入一个循环,所以listOfSeats始终调用该函数,程序永远不会停止运行.问题是它只运行一次,我不能保证我在阵列座位中更改的值被更改.我不知道为什么会这样,请帮忙.当我添加一个调试器来查看它崩溃的原因时,我得到了这个ScreenShot 1ScreenShot2.请帮助我真的不明白这意味着什么.

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
string listOfSeats();
const int arraySize = 20;

int main() {
    while(true) {
        cout << "These are the type of seats we offer during the flight and their current status:\n";
        cout << "(LW) Left Window\n(AL) Aisle left\n(AR) Aisle Right\n(RW) Right Window\n\n";
        listOfSeats();
    }
}

string listOfSeats() {
    string typeOfSeat;
    int numOfSeat;
    static string seat[ arraySize ];

    for ( int i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

c++ loops function

2
推荐指数
1
解决办法
265
查看次数

标签 统计

c++ ×1

function ×1

loops ×1