0% found this document useful (0 votes)
25 views

Piling A C Program

The document discusses the steps to compile a C program: 1) creating the program, 2) compiling the program, and 3) linking the program with any necessary library functions. It notes that compilers come with integrated development environments and text editors. Compilers only accept standard text files. The exact compilation method depends on the compiler, and linking may be part of the compiler or separate. It then discusses the four memory regions used by a compiled C program: the program code memory, global variable memory, the stack, and the heap. The stack holds function calls and local variables while the program runs. The heap is used for dynamic memory allocation. Although physical memory layouts vary, conceptually programs use these four memory regions.

Uploaded by

aditya jain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Piling A C Program

The document discusses the steps to compile a C program: 1) creating the program, 2) compiling the program, and 3) linking the program with any necessary library functions. It notes that compilers come with integrated development environments and text editors. Compilers only accept standard text files. The exact compilation method depends on the compiler, and linking may be part of the compiler or separate. It then discusses the four memory regions used by a compiled C program: the program code memory, global variable memory, the stack, and the heap. The stack holds function calls and local variables while the program runs. The heap is used for dynamic memory allocation. Although physical memory layouts vary, conceptually programs use these four memory regions.

Uploaded by

aditya jain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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