#include<stdio.h>
void main()
{
char ***p="hello";
printf("%c",++*p++);
}
I haven’t understand why the (*) indirection operator used here three times.
When i compiled this program then the output was “j”.
But actually hear the p is a pointer to pointer to pointer to Array of character.
Then why i getting the output as j.
I didn’t understand what’s the logic behind this.
Please help me to understand the actual logic behind this.
And the confusion increase more when I only use one indirection operator and get complied the program .then the output is i.means
void main()
{
char *p="hello";
printf("%c",++*p++);
}
First, it is an undefined behavior.
Second, it isn’t a correct C (or C++) code either. It generates this warning due to non-const char pointer.
Better do it this way:
And regarding what it prints: the program has requested the run-time to terminate it in an unusual way. But this is an undefined behavior – your results may vary.