C++ program does not run if a vector has any contents

Viewed 203

If I run this code in VScode using the g++ build settings it does not output anything. Unless I comment out "std::vector myvector = {10,20,30,40,50};" in which case it prints as expected. I found this out because using push_back() has the same effects.

#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    std::vector<int> myints;
    std::cout << "0. size: " << myints.size() << '\n';
    std::vector<int> myvector = {10,20,30,40,50};
    return 0;
}

Setup: VScode, MSYS MinGW X64, g++ build tasks.

Haven't experienced an issue like this, if you have a better way of making a dynamic array I'll stick with that.

0 Answers
Related