aboutsummaryrefslogtreecommitdiff
path: root/semestre 3/structures des données/tme/tme1-2/exo1/tme1_exo1p1.c
blob: 51b6d927624b07ff84a70d049851929980eb7153 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
#include<stdlib.h>

const static int len = 10;

int main(void) {
    int *tab;
    /* etait en unsigned */
    int i;

    tab = (int*)malloc(len*sizeof(int));

    /* quand etait en unsigned, on avait un overflow a cause du i--, ce qui le remettait en positif
     * ainsi, la boucle ne s'arretait jamais 
     */
    for (i=len-1; i>=0; i--) {
        tab[i] = i;
    }

    free(tab);
    return 0;
}