This code throws "Access violation reading location 0xCCCCCCCC" exception. It occurs due to nullpointer at line "p[i][j]=0.;". How could I handle the problem by changing only the underlined expressions in the commented lines. Basically, it should correctly allocate, initialize and deallocate a matrix.
It occurs due to nullpointer at line "p[i][j]=0.;"
0xCCCCCCCCC is not a null pointer. It's an uninitialized pointer being dereferenced, so your evaluation of the problem is not correct. Furthermore, one cannot correct the problem by "changing only the underlined expressions."
In the alloc function, it should be obvious that we wish to change the address contained by A so passing A by value is not going to get the job done. One could pass by reference, or one could pass the address of the A variable to the function. From the style of your code it appears as if the latter would be the solution, so the function prototype for alloc would be: int alloc(double*** p).
> In the alloc function, it should be obvious that we wish to change the address contained by A init(A, alloc(A))
undefined behaviour (evaluation order)
You haven't "solved it." You've only made it compile. The code is still a bit nonsensical and results in undefined behavior. I would expect such code to look more like the following: