[Solved] How to dynamically allocate memory in 2D array and store values? [closed]
As i said problem is in scanning N and M variables. Change scanf(“%d %d”,&N,&N); to scanf(“%d”,&N); scanf(“%d”,&M); and you are fine. Problem was you were reading N twice while didnt read an M which was used uninitialized. Non-static variables (local variables) are indeterminate. Reading them prior to assigning a value results in undefined behavior. You … Read more