Il existe une erreur de segmentation bizarre. Le code suivant fonctionne très bienErreur de segmentation avec le tableau 2D
#include <stdlib.h>
#include <stdio.h>
main()
{
int matrixSize = 1000;
int i,j;
double a[matrixSize][matrixSize];
for (i = 0; i < matrixSize; i++)
for (j = 0; j < matrixSize; j++)
a[i][j] = rand() % 10;
double b[matrixSize][matrixSize];
for (i = 0; i < matrixSize; i++)
for (j = 0; j < matrixSize; j++)
b[i][j] = rand() % 10;
return 0;
}
Mais lorsque je tente d'initialiser un tableau 2D plus, je reçois exception "défaut de segmentation":
#include <stdlib.h>
#include <stdio.h>
main()
{
int matrixSize = 1000;
int i,j;
double a[matrixSize][matrixSize];
for (i = 0; i < matrixSize; i++)
for (j = 0; j < matrixSize; j++)
a[i][j] = rand() % 10;
double b[matrixSize][matrixSize];
for (i = 0; i < matrixSize; i++)
for (j = 0; j < matrixSize; j++)
b[i][j] = rand() % 10;
return 0;
}
Quelle est la cause potentielle?
Les deux exemples de code sont identiques. – kennytm
pourquoi est-ce marqué comme C++? – shuttle87
J'ai supprimé la balise C++. – tpg2114