[Solved] Segmentation fault (core dumped) if I don’t include a cout? [closed]


Start allocating memory from index 0 onwards, since indexing in C/C++ is from 0 and not 1.

for (int i = 0; i < 5; i++)

Also, replace i by i - 1 in all number[i][j] above. Like number[1][1] = 1. by number[0][1] = 1. and so on.

And also, don’t use malloc (and don’t type-cast its result too !), instead use new :

number[i] = new double[Ntot];

2

solved Segmentation fault (core dumped) if I don’t include a cout? [closed]