小编ars*_*ing的帖子

C++ 程序未使用向量进入 for 循环

我在用vector练习,我想push_back();用for循环来push一个元素,但是程序连for循环都进不去,求救!!!

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

int main()
{
    cout << "check ";
    int val;
    vector<char> vec;
    cout << "check " << endl << "Its in the game";
    //those two "check" were to confirm if the program is even running and is it a 
    problem while declaring the vector 

    for(int i = 0; i < vec.size(); i++){
      
      cout << "enter element for vector" << endl;
      cin >> val;
      vec.push_back(val);
      
    }
}

 
Run Code Online (Sandbox Code Playgroud)

c++ for-loop vector cin

0
推荐指数
1
解决办法
88
查看次数

标签 统计

c++ ×1

cin ×1

for-loop ×1

vector ×1