Pointer Arithmetic
#include <stdio.h>
main()
{
char alpha[]={'A', 'B',
'C', 'D', 'E'};
char x, *p1, *p2;
p1 = alpha;
p2 = p1 + 2;
x = *p2;
printf("%c%c%c",
x, *p1, *(p2-1));
}
The program prints:
CAB
This is the program
pg329.c.
Previous slide
Next slide
Back to first slide
View graphic version