Horje
copy vector c++ Code Example
copy a part of a vector in another in c++
  // Copying vector by copy function 
copy(vect1.begin(), vect1.end(), back_inserter(vect2)); 
copy vector c++
// C++ code to demonstrate copy of vector
// by iterative method.
#include<iostream>
#include<vector>
using namespace std;
  
int main()
{
    // Initializing vector with values
    vector<int> vect1{1, 2, 3, 4};
  
    // Declaring new vector
    vector<int> vect2;
  
    // Using assignment operator to copy one
    // vector to other
    vect2 = vect1;
  
    cout << "Old vector elements are : ";
    for (int i=0; i<vect1.size(); i++)
        cout << vect1[i] << " ";
    cout << endl;
  
    cout << "New vector elements are : ";
    for (int i=0; i<vect2.size(); i++)
        cout << vect2[i] << " ";
    cout<< endl;
  
    // Changing value of vector to show that a new
    // copy is created.
    vect1[0] = 2;
  
    cout << "The first element of old vector is :";
    cout << vect1[0] << endl;
    cout << "The first element of new vector is :";
    cout << vect2[0] <<endl;
  
    return 0;
}
copy file to vector c++
//Read file to the end
while(inFile.read(reinterpret_cast<char*>(&temp), sizeof(temp)))
{
    //Store each int in the vector
    myVector.push_back(temp);
}




Cpp

Related
data type c++ Code Example data type c++ Code Example
lap trinh file explorer c++ Code Example lap trinh file explorer c++ Code Example
C++ Volume of a Cube Code Example C++ Volume of a Cube Code Example
add comment in c/c++ Code Example add comment in c/c++ Code Example
inorder to postorder converter online Code Example inorder to postorder converter online Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8