There is a weird segmentation fault error. The following code runs fine
#include
#include
main()
{
int matrixSize = 100
As tpg2114 says allocating as large matrices is not a good idea. Easiest is to allocate it like that
double (*a)[matrixSize] = malloc(sizeof(double[matrixSize][matrixSize]));
.
free(a);
Then you can continue to use your nested for
loops for initialization without problems as before.
NB:
main
is not conforming to the standard. In your
case you should use int main(void) { ... }
. since a conforming compiler should capture this, it looks that you don't use the correct options for your compiler or that you ignore warnings that he gives you.matrixSize
, i
and j
should be of type size_t
and not int
.