I have a program which is giving different output on different compiler.
#include<stdio.h>
int main()
{
char arr[] = "abcdef";
char *p = arr;
while(*p != '\0')
{
char b = *p;
*p++ = *(p+1);
*p++ = b;
}
printf(" %s", arr);
getchar();
return 0;
}
When I am compiling this using gcc compiler it gives output "badcfe". But when using other compiler, it is giving "caec". Can someone please help me out how does it has two different outputs (with explanation).