Why would I have a segmentation fault when declaring a variable in a C program?
<p>After having a segmentation fault in a C program I am developing, I realized the error came from my declaration of a variable.</p>
<p>It is the first time I tried to declare a variable of  data type Ens_participants defined below:</p>
<pre><code>typedef struct 
{
    int cardinal;
    Participant tab[NB_MAX_PARTICIPANTS];
} Ens_participants;
</code></pre>
<p>And Participant is another data type I created defined below:</p>
<pre><code>typedef struct 
{ 
    char nom[TMAX_MOT];
    char prenom[TMAX_MOT];
    char email[TMAX_MOT];
    char nationalite[TMAX_MOT];
    char langues_parles[LMAX][TMAX_MOT];
    char langues_cherches[LMAX][TMAX_MOT];
    int age;
    char sexe;
    char universite[TMAX_MOT];
    char disponible[TMAX_MOT];
} Participant; 
</code></pre>
<p>With TMAX_MOT, NB_MAX_PARTICIPANTS, and  LMAX being constants :</p>
<pre><code>#define TMAX_MOT 250
#define LMAX 500

#define NB_MAX_PARTICIPANTS 1000
</code></pre>
<p>This is the line that cause my segmentation fault:</p>
<pre><code>Ens_participants les_participants; 
</code></pre>
<p>Did I properly create and declare these variables? How can a single declaration cause a segmentation fault? If it helps, with the gdb debugger, I was told that the error came two lines before this declaration :</p>
<pre><code>int ligne_valide = 1;
</code></pre>
<p>However, this is false as the program worked well with the above line. It is as soon as I tried to declare this new variable that I started having issues.</p>
<h1>UPDATE NO1</h1>
<p>When I changed the value of the constant NB_MAX_PARTICIPANTS to 10 instead of 1000, the program compiled perfectly.</p>
<h1>UPDATE NO2</h1>
<p>I apologize for this question since, as @alk suggested, my problem lies elsewhere. I have rewritten just the types of the program and experimented. The problem is not where I thought it was. The variable definitions and declarations are not causing any issues in the new program.</p>