initial import
[staff/goc4/2018bti7061.git] / c-3-libraries / examples / c-arrays / array4.c
1 #include <stdio.h>
2
3 /* function to generate and return random numbers */
4 int * getRandom( )
5 {
6 static int r[10];
7 int i;
8
9 /* set the seed */
10 srand( (unsigned)time( NULL ) );
11 for ( i = 0; i < 10; ++i)
12 {
13 r[i] = rand();
14 printf( "r[%d] = %d\n", i, r[i]);
15
16 }
17
18 return r;
19 }
20
21 /* main function to call above defined function */
22 int main ()
23 {
24 /* a pointer to an int */
25 int *p;
26 int i;
27
28 p = getRandom();
29 for ( i = 0; i < 10; i++ )
30 {
31 printf( "*(p + %d) : %d\n", i, *(p + i));
32 }
33
34 return 0;
35 }