Originally posted by Kimimaro
Code:
#include <stdio.h>
#include <conio.h>
char *IM1, *IM2, *IM3, *IM4, *IM5 ;
char IMAGINE[7] = {'I', 'M', 'A', 'G', 'I', 'N', 'E'};
main()
{
clrscr();
IM1 = IMAGINE;
IM2 = ++IM1;
IM3 = &IMAGINE[2];
IM4 = IM3 + 2 ;
IM5 = &IMAGINE[4] - 3 ;
printf ("%c\t%c\t%c\t%c\t%c", *IM1,*IM2,*IM3,*IM4,*IM5);
getch();
return 0;
}
kimimaro just think of like this
Code:
IM1 --> IMAGINE(WHICH IS NOTHING BUT THE LIST ELEMENT OF THE ARRYA)
SO NOW IM1 IS POINTING TO 'I'
IM2 <-- ++IM1 (U ARE PRE INCEMENTING THE POINTER IM1 AND NOW IT IS POINTING TO 'M'
AND YOU ARE GIVING THE ADDRESS OF IMAGINE[1] THROUGH THE IM1 POINTER JUST BY INCRMENTING IT)
or in can write this like this
IM2=&IMAGINE[1] WHICH IS EQUAL TO IM2= ++IM1
that is why it is printing u 'M' twice
s.s.harish