how to initialize a vector to 0 in c++ code example
Example 1: initialize all elements of vector to 0 c++
vector<int> vect1(10); //number of elements in vector
int value = 0;
fill(vect1.begin(), vect1.end(), value);
Example 2: c++ initialize a vector
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main()
{
// This vector initializes with the values: 10, 20, and 30
vector<int> vect{ 10, 20, 30 };
return 0;
}