viewing paste Playing with Pointers | C++

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include <iostream>
 
int main () {
    
    int* A = new int[10];
    int n = 5;
    
    
    int i = 0;
    int* p = A;
    int* q = A;
    q += 7;
    while (p != q) {
        std::cout << (*p) << " ";
        p++;
    }
    
    
    std::cout << "\n\n---- LINE BREAK ----\n\n";
    
    i = 0;
    p = &(A[0]);
    while (i < n) {
        std::cout << (*p) << " ";
        i++;
        p++;
    }
    
    return 0;
}
Viewed 1656 times, submitted by Streusel.