topical media & game development
professional-program-21-ArrayIterators-ArrayIterators.c
? /
professional-program-21-ArrayIterators-ArrayIterators.c
include <vector>
include <iostream>
using namespace std;
int main(int argc, char** argv)
{
int arr[10]; // normal C++ array
vector<int> vec; // STL vector
int i;
//
// Initialize each element of the array to the value of
// its index.
//
for (i = 0; i < 10; i++) {
arr[i] = i;
}
//
// Insert the contents of the array into the
// end of the vector.
//
vec.insert(vec.end(), arr, arr + 10);
// print the contents of the vector
for (i = 0; i < 10; i++) {
cout << vec[i] << " ";
}
return (0);
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.