0

我似乎遇到了分段错误的问题。我不确定为什么。

int inputNumber;
vector<string> inputName;
// Input number of inputs
cout << "Enter the number of inputs you will be using" <<endl;
cin >> inputNumber;
while(floor(inputNumber) != inputNumber) {
    cin >> inputNumber;
}
cout << "Input Number reached" << inputNumber <<endl;


//Enter names of vectors
for(int x=0; x>=inputNumber; x++){
    string temp;
    cout << "Enter the name for input " << x << ": ";
    cin >> temp;
    inputName.append(temp);
    cout << x <<endl;
}

标有 cout << "输入号码到达" << inputNumber << endl; 运行得很好。之后它会出现分段错误。我假设它涉及引用向量,但我不太确定。

4

0 回答 0