Module: Pointers


Problem

1/1

Negative array index

Theory Click to read/hide

Index – this is a variable that can store the address of any variable of the given type.
Announcement:
char *pC; // address of a character or array element
int *pI; // address of an integer variable

How to assign an address:
int m = 25, *pI;
pI = &m; // address of variable m

Displaying a value through a pointer:
cout<<*pI;

Since the array variable points to the first element of the array,
int A[] = {5 , 10}, *pI;
pI = A;

will be similar:
int A[] = {5 , 10}, *pI;
pI = &A[0];

to move to the address of the next array element, just do:
pi++;

Problem

Given the string "12345abcd". Create a pointer such that index zero points to the last character.
 
Examples
# Input Output
1 0 d
2 -8 1