Question: How do you do the commented part of this question (its the part that is bolded)? #include #include main(){ int *p, in=10; p = ∈

How do you do the commented part of this question (its the part that is bolded)?

#include #include

main(){

int *p, in=10; p = ∈ printf("%d ", *p );

char arr[]="hello"; char *ptr = arr;

// different ways to pass the array, at "pointer" level. printf("%s %s %s ", arr, &arr[0], ptr);

//different ways to access arr[0] printf("%c %c %c %c ", arr[0], *ptr, *arr, ptr[0]);

//different ways to access arr[1] printf("%c %c %c %c ", arr[1], *(ptr+1), *(arr+1), ptr[1] );

//different ways to access arr[4] printf("%c %c %c %c ", arr[4], *(ptr+4), *(arr+4), ptr[4] );

/****simple array of int pointers **********************************/

int i=1; int j=3; int k; int n; int * x[3]; // array of 3 int pointers x[0]= &i; x[1]= &j; x[2]= &k;

// set k to 5 via its pointer

n=0; for (; n<3; n++) ;// printf("%d %d", , ) // print elements of array x; using both array notation and pointer notation. Should print 1 1 ,3 3, 5 5

/***** array of char pointers, each pointer points to an char array *********************************/

char * planets[] = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"};

// print the pointee of the 1st element pointer (i.e., string "Mercury") in the pointer array, using both array index notation i.e., planets[i] and pointer notation,

// print the pointee of the 2nd element pointer (i.e., string "Venus"), using both array index notation and pointer notation,

// print the pointee of the 5th element pointer (i.e., string "Jupiter"), using both array index notation and pointer notation,

// print the pointee of the 6th element pointer (i.e., string "Saturn"), using both array index notation and pointer notation,

// print the pointee of the 8th element pointer (i.e., string "Neptune"), using both array index notation and pointer notation,

// declare a pointer pp (what type??) to point to the first element of planets;

// print the pointee of the 1st element pointer (i.e., string "Mercury") in the pointer array, via pp and using pointer notation,

// print the pointee of the 2nd element pointer (i.e., string "Venus"), via pp and using pointer notation,

// print the pointee of the 5th element pointer (i.e., string "Jupiter"), via pp and using pointer notation,

// print the pointee of the 6th element pointer (i.e., string "Saturn"), via pp and using pointer notation,

// print the pointee of the 8th element pointer (i.e., string "Neptune"), via pp and using pointer notation,

/* access the characters in the pointee strings. */ printf("%c %c %c %c ", *( *(planets+4) +3 ), planets[4][3], *( *(pp+4) +3 ), pp[4][3] ); printf("%c %c %c %c ", **planets, planets[0][0], **pp, pp[0][0] ); // *( *(planets+0) +0 ), }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!