Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

📚 The CoCalc Library - books, templates and other resources

Views: 96113
License: OTHER
1
/* Example code for Think OS.
2
3
Copyright 2014 Allen Downey
4
License: GNU GPLv3
5
6
*/
7
8
#include <stdio.h>
9
#include <stdlib.h>
10
11
int global;
12
13
void recurse (int n)
14
{
15
int a[4000];
16
int x;
17
void *q = malloc(128);
18
19
printf ("Address of a is %p\n", &a[0]);
20
printf ("Address of x is %p\n", &x);
21
printf ("Address of q is %p\n", q);
22
23
if (n > 0) recurse (n-1);
24
}
25
26
int main ()
27
{
28
int local = 5;
29
void *p = malloc(128);
30
31
printf ("Address of main is %p\n", main);
32
printf ("Address of global is %p\n", &global);
33
printf ("Address of local is %p\n", &local);
34
printf ("Address of p is %p\n", p);
35
36
recurse (1);
37
return 0;
38
}
39
40