The code is mostly invalid C all over the place. Do yourself a favour and stop chasing bugs that the compiler has already found, as well as stop examining the output of "not C" undefined behavior programs, by configuring your compiler as a conforming C compiler instead: What compiler options are recommended for beginners learning C?
p = arr;
This is invalid C. Anything can happen.
p = (char*)((int*)(p));
This line achieves absolutely nothing.
p = (int*)(p+1);
This is invalid C. Anything can happen.
If we fix the problem in your program as
#include <stdio.h>
int main(){
int arr[3] = {2, 3, 4};
char *p;
p = (char*)arr;
printf("%d, ", *p);
p++;
printf("%d", *p);
return 0;
}
We do get the output 2, 0
on an little endian machine. On a 32 bit little endian machine, int arr[3] = {2, 3, 4};
is stored in memory as (lowest to highest address):
02 00 00 00 03 00 00 00 04 00 00 00
So if you examine the array byte by byte, that's what you'll get. For more info see What is CPU endianness?