I am unable to initialize a vector in C++ macOS, VSCode. I looked at possible solutions, but i did not find any solution. I'm stuck at this point
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v{3, 5, 5, 1};
for (int i = 0; i < v.size(); i++)
{
cout << v[i] << " ";
}
}
This is my error:
text2.cpp:9:18: error: expected ';' at end of declaration
vector<int> v{3, 5, 5, 1};
^
;
1 error generated.
This is my tasks.json file.
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-fdiagnostics-color=always",
"-std=c++17",
"-stdlib=libc++",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}",
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}