07-outofbound_access.c 329 Bytes
Newer Older
Xavier Besseron's avatar
PS 2021  
Xavier Besseron committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <stdlib.h>



int main(int argc, char** argv)
{
  int size = 100;

  double *fibo = malloc( sizeof(double) * size );
  fibo[0] = 1; fibo[1] = 1;

  int i;
  for( i = 1 ; i < size ; i++ )
  {
    fibo[i] = fibo[i-1] + fibo[i-2];
  }

  printf(" fibo = %f\n", fibo[size] );

  free(fibo);

 return 0;
}