Search
 
SCRIPT & CODE EXAMPLE
 

CPP

array copx c++

#include <algorithm> //Only needed for Option 1
#include <iostream>

using namespace std;

int main() {
  	//Option 1
    const int len{3};
    int arr1[len] = {1,2,3};
    int arr2[len]; //Will be the copy of arr1
    copy(begin(arr1), end(arr1), begin(arr2));
  
  	//Use the following, if you are not using namespace std;
    //std::copy(std::begin(arr), std::end(arr), std::begin(copy));
  
    //Option 2
    int arr3[len]; //Will be the copy of arr1
    for(int i = 0; i<len; ++i) {
      arr3[i] = arr1[3];
    }
    
    return 0; //exitcode
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: Initialize Vector Iterator 
Cpp :: print reverse number 
Cpp :: basic cpp 
Cpp :: printing in column c++ 
Cpp :: matrix c++ 
Cpp :: what library is rand in c++ 
Cpp :: what is function c++ 
Cpp :: linear search 
Cpp :: how to print items in c++ 
Cpp :: stoi in c++ 
Cpp :: Array declaration by specifying the size in C++ 
Cpp :: c++ stl vector get iterator from index 
Cpp :: C++ detaching threads 
Cpp :: c++ include < vs "" 
Cpp :: How to pass a multidimensional array to a function in C and C++ 
Cpp :: #define in cpp 
Cpp :: C++, binary search recursive 
Cpp :: how to insert in a queue c++ 
Cpp :: valid parentheses in c++ 
Cpp :: c++ power of two 
Cpp :: min heap 
Cpp :: binary to decimal online converter 
Cpp :: print all number between a and b in c++ 
Cpp :: enter items in array until enter is pressed c++ 
Cpp :: lap trinh file explorer c++ 
Cpp :: c++ round number to 2 decimal places 
Cpp :: variable modulus 5 meaning in c++ 
Cpp :: c++ to mips converter online 
Cpp :: strong number in c++ 
Cpp :: C++ Multilevel Inheritance 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =