-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db435e7
commit 1e9ed06
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
char globBuf[65536]; /* Uninitialized data segment */ | ||
int primes[] = { 2, 3, 5, 7 }; /* Initialized data segment */ | ||
static int | ||
square(int x) /* Allocated in frame for square() */ | ||
{ | ||
int result; /* Allocated in frame for square() */ | ||
result = x * x; | ||
return result; /* Return value passed via register */ | ||
} | ||
static void | ||
doCalc(int val) /* Allocated in frame for doCalc() */ | ||
{ | ||
printf("The square of %d is %d\n", val, square(val)); | ||
if (val < 1000) { | ||
int t; /* Allocated in frame for doCalc() */ | ||
t = val * val * val; | ||
printf("The cube of %d is %d\n", val, t); | ||
} | ||
} | ||
int | ||
main(int argc, char *argv[]) /* Allocated in frame for main() */ | ||
{ | ||
static int key = 9973; /* Initialized data segment */ | ||
static char mbuf[10240000]; /* Uninitialized data segment */ | ||
char *p; /* Allocated in frame for main() */ | ||
p = malloc(1024); /* Points to memory in heap segment */ | ||
doCalc(key); | ||
exit(EXIT_SUCCESS); | ||
} |