Answer the question
In order to leave comments, you need to log in
What value is obtained after denaming the pointer?
Please explain how to dereference a pointer
in a string
*(ptr+i*B+j)
int DIM[A][B];
int *ptr = (int *) DIM;
for (int i=0; i<A; i++)
{
for (int j=0; j<B; j++)
{
cout << setw(4) << *(ptr+i*B+j) << endl;
}
cout << endl;
}
Answer the question
In order to leave comments, you need to log in
For pointers (type *), adding/subtracting an integer moves the pointer forward/backward by the size of the sizeof(type) element.
int A[3];
int *ptr = A; // ptr указывает на A[0]
ptr += 2; // ptr указывает на A[2]
ptr --; // ptr указывает на A[1]
ptr = ptr+10; // ptr указывает за пределы массива A
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question