0

A problem with dynamic matrix in C

I was playing with memory allocation in C and I really don't know what's wrong with code below. Segmentation fault occurs if I run it, but if I comment the print_matrix() function in main(), nothing wrong happens. https://code.sololearn.com/cAznSKpm1dv8/#c It's really confusing for me, but the print_matrix() seems to cause the problem.

5th Jan 2020, 8:30 PM
RadosƂaw Biedrzycki
RadosƂaw Biedrzycki - avatar
1 Answer
+ 1
Line 21 and 22 is overwriting the pointers line 19 stored. Plus, many more. This is updated to work. https://code.sololearn.com/cWAhrO4jFx17
6th Jan 2020, 9:44 PM
John Wells
John Wells - avatar