I've just started programming in C a month ago and I apparently don't understand something about memory allocation even though I've read about it from few different sources.
If somebody could explain why this easy example I made crashes, I would be very grateful. (sorry for bad english)
void test(double *x)
{
x = (double *)malloc(2 * sizeof(double));
x[0] = 2;
x[1] = 3;
}
int main()
{
double *x = NULL;
test(x);
printf(" %f", x[0]); //this is where it crashes with no message
}