Answer to Question #264307 in C++ for Amit

Question #264307

Modify the program by creating an array of n objects using pointers. Show the details of n items by using pointers to object concept.


1
Expert's answer
2021-11-12T05:06:50-0500


#include<stdio.h>


int main()
{
    // Pointer to an integer
    int *p;


    // Pointer to an array of 5 integers
    int (*ptr)[5];
    int arr[5];


    // Points to 0th element of the arr.
    p = arr;


    // Points to the whole array arr.
    ptr = &arr;


    printf("p = %p, ptr = %p\n", p, ptr);


    p++;
    ptr++;


    printf("p = %p, ptr = %p\n", p, ptr);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS