why this code gives error

main()
{
int *x;
*x = 5;
printf("%d",*x);
}


it works with some compiler but not with others. If I use malloc, then it works fine everywhere. Can you tell why?