-
code
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
char *ptr="string";
clrscr();
printf("%c",*ptr++);
printf("%c",*(++ptr));
printf("%c".(*ptr)++);
printf("%c",++*ptr);
getch();
}
output:
srrt
please explain how am i getting output as srrt
urgent please response soon.
explain the logic how am getting this output
-
Concentrate on these two lines:
Code:
printf("%c",*ptr++);
printf("%c",*(++ptr));
In particular, recall how post-increment and pre-increment works.
Ignore these two lines as they result in undefined behaviour since they modify what ptr points to, which is the contents of a string literal:
Code:
printf("%c".(*ptr)++);
printf("%c",++*ptr);