Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int a[7] = {0, 6, 5, 3, 2, 4, 1}; // static array
- int* b = new int[7];
- int n = 0;
- // copy a into b using pointers
- for (int* p = a; p < a+7; ++p)
- {*b= *p;
- ++b;}
- b=b-7;
- // cross-check with random access
- for (int i = 0; i <= 6; ++i)
- if (a[i] != b[i])
- std::cout << "Oops, copy error...\n";
- delete[] b;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement