GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


appending an array to a vector by godecho
1
 
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
        int array[3];
        array[0] = 3;
        array[1] = 4;
        array[2] = 5;


        vector<int> vec(3);
        vec[0] = 0;
        vec[1] = 1;
        vec[2] = 2;

        vec.insert(vec.end(), array, array+3);

        copy(vec.begin(), vec.end(), ostream_iterator<int>(cout, " "));

        return 0;
}