Added stack address randomization example.
[C-Programming-Examples.git] / variable_arrays.c
blob477e5257f55397bc2e70dd62c53584dd27c5ea1d
1 /*
3 Demonstation of variable arrays.
4 Only works with compilers that support C99
6 */
8 #include <stdio.h>
10 int main()
12 int i, n;
14 printf("How many numbers do you want to reverse? ");
15 scanf("%d", &n);
17 int a[n]; /* C99 Only */
18 printf("Enter %d numbers: ", n);
19 for(i = 0; i < n; i++)
20 scanf("%d", &a[i]);
22 printf("In reverse order:");
23 for(i = n - 1; i >= 0; i--)
24 printf(" %d", a[i]);
25 printf("\n");
27 return 0;