You are on page 1of 2

LearnGood Academy C Programming

1.5. Compiling a C Program

Creating an executable form of your C program consists of these three steps:

1. Creating your program

2. Compiling your program

3. Linking your program with whatever functions are needed from the library

Today, most compilers supply integrated programming environments that include an


editor. Most also include stand-alone compilers. For stand-alone versions, you must
have a separate editor to create your program. In either case, be careful: Compilers only
accept standard text files for input. For example, your compiler will not accept files
created by certain word processors because they contain control codes and non printing
characters.

The exact method you use to compile your program will depend upon what
compiler you are using. Also, how linking is accomplished will vary between compilers
and environments; for example, it may be included as part of the compiler or as a stand-
alone application. Consult your compilers documentation for details.

1.6. Cs Memory Map

A compiled C program creates and uses four logically distinct regions of memory. The
first region is the memory that actually holds the programs executable code. The next
region is memory where global variables are stored. The remaining two regions are the
stack and the heap. The stack is used for a great many things while your program
executes. It holds the return addresses of function calls, arguments to functions, and
local variables. It will also save the current state of the CPU. The heap is the region of
free memory that your program can use via Cs dynamic memory allocation functions.

Although the exact physical layout of each of the four regions of memory differs
among CPU types and C implementations, the diagram in Figure 1-2 shows conceptually
how your C programs appear in memory

LearnGood Academy THE VERY BEST UDEMY C PROGRAMMING COURSE Page 7


LearnGood Academy C Programming

Stack

Heap

Global variables

Program code

Conceptualized memory map of a C program

LearnGood Academy THE VERY BEST UDEMY C PROGRAMMING COURSE Page 8

You might also like