Anda di halaman 1dari 35

Introduction to Programming in C

Douglas C. Schmidt
University of California, Irvine
Based on Material Prepared by
obert C. Carden I!, Ph.D.
Unisys Corporation
Mission !ie"o, California
e#uired te$tboo%s
David R. Brooks, C Programming& 'he (ssentials )or (ngineers *nd Scientists,
Springer, New York.
Al Kelley and Ira Pohl, * Boo% +n C, fourh ediion, !he Addison"#esley Pu$lishing
%o&pany, Reading, 'assa(huses
)a&&a, *el&, +ohn, and ,lissides, Design Patterns& (lements of eusable Soft,are
Components, !he Addison"#esley Pu$lishing %o&pany, Reading, 'assa(huses
ecommended te$tboo%
Brian Kernighan and Dennis Ri(hie, 'he C Programming -anguage, se(ond ediion,
Preni(e *all, New +ersey.
ecommended boo%s on the C language
Ka&al B. Ro-iani, Programming in C ,ith .umerical Methods )or (ngineers,
Preni(e *all, New +ersey.
A"Series % 'anual ./nisys %orporaion0, referen(e nu&$er 1234 5663"444, New +ersey.
ANSI Draf on he % Progra&&ing 7anguage, 81.932"9252
ecommended boo%s covering advanced C language topics
Narain )ehani, *n *dvanced C Introduction& *.SI C (dition, %o&puer S(ien(e
Press, Ro(kville, 'aryland
Copyright (c) 1998 by Robert C. Carden IV, Ph.D.
5:95:;49<
Introduction to Programming in C
Andrew Koenig, C 'raps and Pitfalls, Addison"#esley Pu$lishing %o&pany, Reading,
'assa(huses
1-
Introduction to Programming in C
Seven R. 7er&an, Problem Solving and Computation for Scientists and (ngineers&
*n Introduction Using C, Preni(e *all, New +ersey
#. Ri(hard Sevens, *dvanced Programming in the U.I/ (nvironment, Addison"
#esley Pu$lishing %o&pany, Reading, 'assa(huses
#. Ri(hard Sevens, U.I/ .et,or% Programming, Addison"#esley Pu$lishing
%o&pany, Reading, 'assa(huses
Ro$er Sedgewi(k, *lgorithms in C, Addison"#esley Pu$lishing %o&pany, Reading,
'assa(huses
*dditional references
'ark Allen #eiss, Data Structures and *lgorithm *nalysis, !he Ben-a&in:%u&&ings
Pu$lishing %o&pany, Redwood %iy, %A
Paul #ang, *n Introduction to Ber%eley Uni$, #adsworh Pu$lishing %o&pany,
Bel&on, %A
Peer A. Darnell, Philip =. 'argolis, Soft,are (ngineering in C, Springer",erlag, New
York, NY.
P.+. Plauger, 'he Standard C -ibrary, Preni(e *all, =nglewood %liffs, N+
Class +b"ectives
1-!
Introduction to Programming in C
'he ob"ectives of this class are as follo,s&
!ea(h you how o read % progra&s
!ea(h you how o ,rite % progra&s
!ea(h you how o debug % progra&s
!ea(h you how o design good % progra&s
'his is a class for developers, not managers
'anagers are (erainly invied o aend, $u hey &us plan o
do real work
If you are aking his (lass o see wha % is all a$ou wihou
planning on really learning i and progra&&ing i, you are in he
wrong (lass>
0o, to Succeed in this Class
*ttend class
1-"
Introduction to Programming in C
?24 per(en of life is -us showing up.? ""#oody Allen
=@a&s are heavily $ased on &aerial presened in (lass1
.ever miss more than one consecutive ,ee% of classes
If you -us have o ake ha wo week va(aion, plan i so ha
you only &iss one week of (lasses "" really>
'issing even one (lass will severely li&i your a$iliy o keep
up, pari(ularly wr he e@a&s
ead ahead
Do the home,or%
Sudens wih a previous progra&&ing .e.g. Pas(al or %AA0
$a(kground should plan on spending 2345 hours per week
Sudens wih a no programming background $u computer
literate 45365 hours per week
Sudens wih a no programming background and no computer
experience 65375 hours per week...you will $e spending a lo of
i&e sruggling wih he ools as well as learning how o
progra&
!he $es plan of a(ion is o do a lile $i of he la$ assign&en
work ea(h day, pari(ularly if you have a ho&e (o&puer
!he wors plan of a(ion is o do everyhing he nigh $efore he
ho&ework is due
*s% #uestions
1-#
Introduction to Programming in C
0o, to )ail in this Class
Miss t,o consecutive ,ee%s of class sessions
'ry to survive ,ithout access to a C compiler
You learn % $y doing, i.e., you &us wrie % progra&s, (o&pile
he&, and run he&
.ever spend any time on this outside of class
Do not attempt any of the home,or%
0abitually sho, up late for class or habitually leave early
The bottom line is that you will get out of this class
what you put into it!!!
!o su((eed, you need o spend a leas 3 o 94 hours per week
on your own
1-$
Introduction to Programming in C
+vervie, of a Computer 3 0ard,are
eference& Broo%s, Chapter 48 9P, Chapter 4
%enral Pro(essing /ni .%P/0 (onrols he flow of insru(ions and daa and perfor&s
he ne(essary &anipulaion of daa
Pri&ary sorage .&e&ory0 is used o sore infor&aion for i&&ediae a((ess $y he
%P/
Noe ha here are &any levels of cache used in pri&ary sorage
Se(ondary sorage devi(es .e.g., he hard drive, %D"RB' drives, apes, e(.0 provide
per&anen sorage of large a&ouns of daa, $u are &u(h slower han pri&ary sorage
Inpu and Bupu devi(es provided inerfa(es $eween he (o&puer and he user
1-%
Secondary
Storage
Primary
Storage
Control
Unit
Arithmetic
Logic Unit
Centra& Proce''ing
(nit
(CP()
Input
Devices
Output
Devices
Introduction to Programming in C
+vervie, of a Computer 3 Data epresentation
!he firs (o&puers used va(uu& u$es o hold daa
,a(uu& u$es have wo saes " BN and BCC
An BN sae represens a 9
An BCC sae represens a 4
=igh va(uu& u$es srung ogeher (an represen an 5 digi sring of 4s and 9s
Pu anoher way, his sring is an 5 digi $inary .$ase ;0 nu&$er
#e use de(i&al .$ase 940 nu&$ers in our daily life
A de(i&al nu&$er is a sring of digis whose values are drawn fro& he se
D4,9,;,1,<,3,E,6,5,2F
In general, a nu&$er syse& is si&ply a way of represening nu&$ers
A nu&$er syse& has a $ase .he nu&$er of digis used in he nu&$er syse&0
%onsider a nu&$er in a $ase b nu&$er syse&G
!he value of his nu&$er isG
A binary nu&$er has a $ase of ; where he valid digis are 4 or 9
=.g., 9449 $inary HH 2 de(i&al .9I5 A 4I< A 4I; A 90
An octal nu&$er has a $ase of 5 where he valid digis are 4 hrough 6
=.g., 419 o(al HH ;3 de(i&al .1I5 A 90
A decimal nu&$er has a $ase of 94 where he valid digis are 4 hrough 2
=.g., ;444 de(i&al HH ;444 .Y;K $ug J"00
A he$adecimal nu&$er has a $ase of 9E where he valid digis are 4 hrough C, i.e.
D4,9,;,1,<,3,E,6,5,2,A,B,%,D,=,CF
=.g., @ABBA he@ HH <12E; de(i&al .94I<42E A 99I;3E A 99I9E A 940
1-8
4 9 9
a a a a
n n

4
4
9
9
9
9
b a b a b a b a
n
n
n
n
+ + + +


Introduction to Programming in C
+vervie, of a Computer 3 Data epresentation :6;
Po,ers of 6
6<5
1
6<44
2048 2K
6<4
2
6<46
4096 4K
6<6
4
6<47
8192 8K
6<7
8
6<4=
16,384 16K
6<=
16
6<42
32,768 32K
6<2
32
6<4>
65,536 64K
6<>
64
6<4?
131,072 128K
6<?
128
6<4@
263,144 256K
6<@
256
6<4A
524,288 512K
6<A
512
6<65
1,048,576 1M
6<45
1024 1K
6<64
2,097,152 2M
1 KILO = 2^10 = 1024
1 MEG = 2^20 = 1024*1024 = 1,048,576
1 GIGA = 2^30 = 1024*1024*1024 = 1,073,741,824
!o evaluae a $inary nu&$er, say 949949, si&ply add up he (orresponding powers of
;G
1-9
4 9 ; 1 < 3
; 9 ; 4 ; 9 ; 9 ; 4 ; 9 949949 + + + + + =
<3 9 4 < 5 4 1; = + + + + + =
Introduction to Programming in C
+vervie, of a Computer 3 0e$adecimal .umbers
A he@ade(i&al nu&$er is a sring of he@ade(i&al digis
Digis A, B, %, D, =, C represen he nu&$ers 94, 99, 9;, 91, 9<, and 93
*e@ade(i&al is popular in he (o&puer field $e(ause i (an $e used o (on(isely
represen a long sring of $inary digis
%onsider a 9E digi $inary nu&$erG
1011000111000101
Break his up ino groups of <G
1011 0001 1100 0101
%onver ea(h group of < ino de(i&alG
11 1 12 3
!hen (onver ea(h de(i&al nu&$er ino he@G
B1C3
And you now have he nu&$erG Baker 1 Charlie 3
Able = A = 10 = 1010
Baker = B = 11 = 1011
Charlie = C = 12 = 1100
Dog = D = 13 = 1101
Eas = E = 14 = 1110
!o" = ! = 15 = 1111
By he sa&e oken, he *=8 nu&$er 7)6C42A> represens he $inary sringG
0011 1111 0010 1110 0001 0101 1001 0110
1-1)
Introduction to Programming in C
+vervie, of a Computer 3 Primary Storage
Pri&ary sorage, also known as main memory or RA' .rando& a((ess &e&ory0 is
used o sore infor&aion for i&&ediae a((ess $y he %enral Pro(essing /ni .%P/0
'e&ory (an $e viewed as a series of memory cells wih ea(h (ell having is own
individual address
=.g., hink of a $ank of &ail$o@es a a pos offi(e
!he infor&aion (onained in a &e&ory (ell is (alled he contents of ha (ell
'e&ory (ells (an $e used o sore data, su(h as characters or numbers
Inernally, of (ourse, hey are all nu&$ers, $u we (an (hoose o inerpre so&e
nu&$ers as (hara(ers
!hey (an also $e used o sore program instructions
!hese are Kspe(ialL nu&$ers ha are &eaningful o a %P/>
!he s&alles uni of (o&puer sorage is a bit, as in binary digit
'os (o&puers group $is ogeher o for& larger eniies
=.g., @ (onse(uive $is ofen for& a byte and 76 (onse(uive $is ofen for& a
,ord
A word on an Inel ;5E (o&puer is 9E $is or ; $yes
A word on an Inel 15E, <5E, and Peniu& (o&puers is 1; $is or < $yes
!he ne@ generaion of Inel (o&puers .e.g. he 'er(ed0 will use E< $i words, i.e.
5 $yes
!he D=% Alpha (o&puer is (urrenly using E< $i words
'any &ainfra&e (o&puers, su(h as he /nisys A"Series, use <5 $i words
'e&ory (ells in a (o&puer are ypi(ally one byte or one ,ord in siMe
A word is a uni of infor&aion ha (an $e ransferred o and fro& &e&ory
A %ilobyte of &e&ory, as in 9K, is 94;< $yes of &e&ory
A megabyte of &e&ory, as in 9', is 94;<K of &e&ory, or ;N;4 $yes
A gigabyte of &e&ory, as in 9), is 94;<' of &e&ory, or ;N14 $yes
Noe ha a 1; $i word (an represen ;N1; differen possi$le values
1-11
Introduction to Programming in C
Programming -anguages 3 -o, -evel -anguages
%o&puers only do wha hey are old o do
=@(ep in *ollywood &ovies, e.g., ;449, !er&inaor ;, he 'ari@, e(. J"0
In order for a (o&puer o perfor& a ask, i &us $e given a series of spe(ifi(
insru(ions in a language i (an undersand
!he funda&enal language of any (o&puer is is machine language
!his is ypi(ally seOuen(es of Meroes and ones
In he very early days of (o&puers, his was he only way one (ould wrie
progra&s>>>
!o relieve he suffering of hese early progra&&ers, a higher level language (alled
assembly language was developed
Asse&$ly language (onains mnemonic words and sy&$ols for he $inary &a(hine
insru(ions
An assembler &aps asse&$ly language insru(ions ino &a(hine language
insru(ions
Asse&$ly language progra&&ing is indeed a signifi(an i&prove&en over &a(hine
language progra&&ing
*owever, i has he following draw$a(ksG
'a(hine dependen " ea(h (o&puer ar(hie(ure has is own uniOue asse&$ly
language
7ow level insru(ions " wriing progra&s is very i&e (onsu&ing, edious, and
error"prone
1-1
Introduction to Programming in C
Programming -anguages 3 0igh -evel -anguages
A general rend in (o&puing over he pas < de(ades is o elevae progra&&ing fro&
low level o higher level languages
I.e., high level languages are geared &ore oward people wriing he progra&s
raher han he (o&puer
Asse&$ly language insru(ions &ap dire(ly o &a(hine insru(ions
*igh level language insru(ions &us $e translated/compiled ino &a(hine
insru(ions
*igh level languages are &ore Kpro$le&"orienedL han asse&$ly:&a(hine languages
=.g, hey reOuire lile or no knowledge of he underlying (o&puer ar(hie(ure
7earning how o wrie:de$ug progra&s in high level languages is &u(h easier and less
error"prone han learning how o wrie:de$ug eOuivalen progra&s in asse&$ler
=.g., high level languages reOuired fewer sae&ens o do he sa&e hing as
asse&$ler
Progra&s wrien in high level languages (an $e pored &u(h &ore easily o differen
(o&puer ar(hie(ures
=.g., he (o&piler en(apsulaes he &a(hine"dependen deails of he arge
asse&$ly language
A spe(ial progra& (alled a compiler is needed o ranslae a progra& wrien in a high
level language ino asse&$ly (ode .whi(h is hen ransfor&ed ino naive &a(hine
(ode $y an assembler0
!he sae&en wrien in he high level language are (alled source code
!he (o&piler:asse&$lerPs oupu is (alled object code
1-1!
*ource
Code
Compi&er +b,ect
Code

-''emb&e
r
Introduction to Programming in C
-anguage 'a$onomy
FORTRAN
FORTRAN IV
FORTRAN77
COBOL
PL/1
ALGOL
BRROG!"
E#TEN$E$
ALGOL
ALGOL68
COBOL85
APL
LI"P
"MALLTALK
PROLOG
PA"CAL
MO$LA%2
A$A
A""EMBLER
B,BCPL
C
AN"I C
C&&
E
1-1"
Introduction to Programming in C
0istory of C
9264PS
=arly 9254Ps
7ae 9254Ps
%
!RADI!IBNA7 %
ANSI %
QBR S!ANDARD %R
A&eri(an
Naional
Sandards
Insiue
81+99 %o&&iee
Add void ype
enu&eraion
oher i&prove&ens
Add void I
fun(ion prooypes
new fun(ion definiion syna@
&ini&u& sandard li$rary
&ore fun(ionaliy o prepro(essor
Add (ons and volaile
sru( as para&eer
1-1#
Introduction to Programming in C
Significant Points *bout C
S&all nu&$er of keywords
#idely availa$le, pari(ularly on personal (o&puers and worksaions
%an $e used very pora$ly
Sandard li$rary
Prepro(essor &ay $e used o isolae &a(hine dependen (ode
/nlike Pas(al, whi(h has &any diale(s
Naive language of /NI8 .&0 and #indows N!
!erse
Powerful se of operaors
Sae&ens (an $e very powerful
So&e are bit level operaors
Designed o $e i&ple&ened effi(ienly on &any &a(hines
'odular "" fun(ions
Para&eers are ypi(ally passed S$y valueT
No nesed fun(ions
Syna@ is (o&pli(aed
Se&ani(s of (erain feaures are (o&ple@ and error"prone
1-1$
Introduction to Programming in C
* Comparison of Programming -anguage Philosophy
Pascal
Sri( Paren .a K$ondage and dis(iplineL language J"00
Resri(s progra&&er for his:her own good
A whie, auo&ai( rans&ission auo&o$ile wih los of safey feaures .e.g., air $ags,
(onrols ha li&i speed o 33 &iles per hour and prohi$i leaving he lighs on or
lo(king he keys in he (ar0
C
A per&issive, easy going paren .a UlassiMe"faireT language J"00
Assu&es ha he progra&&er knows wha he:she is doing and will assu&e
responsi$iliy for his:her a(ions. .So&e des(ri$e i as a Kgun wih whi(h you (an
shoo yourself in he foo.L0
A $righ red TE3 %orvee wih a $ig $lo(k engine, &anual rans&ission, opional sea
$el, and wih fuMMy di(e hanging fro& he rear view &irror.
CBB
A less per&issive, ye open &inded paren .e.g., U!ho&as *u@a$leT J"00
Assu&es ha he progra&&er generally knows wha he:she is doing, $u provides
&ore (he(king $y defaul. .K#ih %AA iTs harder o shoo yourself in he foo, $u
when you do, youTll $low off $oh of your legsL V B-arne Srousrup0
A $righ red ;444 %orvee wih a E speed &anual rans&ission, air $ag, and heads
up display, &any on $oard (o&puers
1-1%
Introduction to Programming in C
($ample C Program
#$
!ile% hello&'
Des'ri()io*% +ri*)s a gree)i*g )o s),o-)&
A-)hor% Do-glas C& .'h/i,) 0s'h/i,)1-'i&e,-2
$#
3i*'l-,e 0s),io&h2
i*) /ai* 45oi,6 #$ e"e'-)io* s)ar)s i* /ai* $#
7
(ri*)8 49:ello ;orl,&<*96=
re)-r* 0=
>
All % progra&s &us have a fun(ion in i (alled main
=@e(uion sars in fun(ion main
% is case sensitiveC
%o&&ens sar wih /* and end wih */. %o&&ens &ay span over &any lines.
% is a Kfree for&aL language.
!he 3i*'l-,e 0s),io&h2 sae&en insru(s he % (o&piler o inser he enire
(onens of file '()*+,- in is pla(e and (o&pile he resuling file.
1-18
Introduction to Programming in C
Compiling a C Program
Bn a personal (o&puer using ,isual Sudio, you will (reae a .( file, e.g. hello.( .as in
he previous e@a&ple0. You will hen (o&pile i o produ(e a .e@e file .e.g., hello.e@e0
and perhaps a .o$- file .hello.o$-0. %onsul your (o&piler do(u&enaion .ea(h one is
differen0.
1-19
Introduction to Programming in C
In ,isual Sudio, do a CileWNew and you will see he following dialog...
1-)
Introduction to Programming in C
*ere, you &us firs sele( Din76 Console *pplication. !hen press he ... $uon ha
appears o he righ of he 7o(aion
1-1
Introduction to Programming in C
Now (hoose he lo(aion. You &ay need o (reae a folder on your file syse&. In his
(ase, I $rough up he #indows N! e@plorer and (reaed he new folder =(e99"s25.
#haever you do, you should pla(e he pro-e( in a pla(e su(h ha you (an easily find
i laer.
1-
Introduction to Programming in C
Now ha you have spe(ified a 7o(aion, i.e. a folder where you wan your pro-e(
(reaed, you should see he following...
1-!
Introduction to Programming in C
Now, spe(ify he na&e of your pro-e(. ,isual Sudio will (reae a folder underneah
he one you spe(ified for 7o(aion $y ha na&e. !his will also $e(o&e he na&e of
your e@e(ua$le... Cinally, (li(k on he +9 $uon o re(ord your sele(ion.
I is very i&poran ha you do ea(h of hese iniial seps in he e@a( order ha I have
des(ri$ed a$ove. !ha is, firs spe(ify ha you wan a %onsole Appli(aion, hen
spe(ify he lo(aion, hen spe(ify he pro-e( na&e. Do not forget any of these steps.
In oher words, pay aenion>>>
1-"
Introduction to Programming in C
As a resul, you will see he following in ,isual Sudio
Noi(e ha he #orkspa(e window now has hree a$s. I has a Class!ie, a$, a
)ile!ie, a$, and an Info!ie, a$. Sele( .poin he &ouse o0 he )ile!ie, a$.
1-#
Introduction to Programming in C
Afer sele(ing he Cile,iew a$, you should see he following. Noi(e wha appears
in he #orkspa(e window...
1-$
Introduction to Programming in C
Now we need o (reae a sour(e file and in(lude i in he pro-e(. If we do he (orre(
seOuen(e of seps, ,isual Sudio will auo&ai(ally in(lude he new file ino he
pro-e(.
Do a )ileE.e, and sele( 'e$t )ile and hen spe(ify a Cile na&e. Do no a((ep he
defaul (hoi(e, *ctive Server Page .or whaever happens o $e he defaul0. Do no
sele( %:%AA *eader Cile. Do no sele( %AA Sour(e Cile. Sele( !e@ Cile. Do no
forge o ype in he file na&e, i.e. hello.( .or whaever you wish o (all i0, but it
must end ,ith .c >>> !he file suffi@ ells ,isual Sudio ,hat type of file this is so i
knows ,hich compiler to invo%e on it. Cinally, (li(k +9 o sele( your (hoi(e.
1-%
Introduction to Programming in C
As a resul of your effors, you should see he following.
1-8
Introduction to Programming in C
I usually &ove he windows around a his poin, ad-using he siMes.
!ype in he progra&.
1-9
Introduction to Programming in C
If you (li(k on he A $y *ello files under #orkspa(e, you will see a lis of all of he
files in your pro-e(
Build your progra& $y sele(ing he BuildEBuild &enu opion
1-!)
Introduction to Programming in C
Run i .Build W =@e(ue0
Now lePs look a he filesG
!.//+,)'0G his is your #BRKSPA%=
!.//+,)'1G his is he pro-e( $uild file
!hese wo files, along wih -.//+,2 are worh saving.
1-!1
Introduction to Programming in C
!he progra& we -us $uil is *=77B.=8= under he De$ug dire(ory
Be(ause i is a %BNSB7= appli(aion, we (an run i dire(ly fro& our #indows N!
(o&&and .or #indows 23 Dos0 pro&p.
#hen I yped hello $elow a he Dos pro&p, #indows ran he progra& hello.e$e.
Below you (an see he resuls of his run.
1-!
Introduction to Programming in C
Compiling Under U.I/
!o (o&pile a % progra& under /NI8, one &ay do i in he following waysG
3 22 -.//+,2
!his (o&piles he file and (reaes an e@e(ua$le na&ed a.out
3 22 -.//+,2 %+ -.//+
!his (o&piles he file $u rena&es he e@e(ua$le hello
3 22 %2 -.//+,2
!his (o&piles he file $u does no link i, hus produ(ing an object &odule whi(h &ay $e
linked laer on. !ha file, $y defaul, is hello.o
3 22 -.//+,+ %+ -.//+
!his links he o$-e( file hello.o o (reae he e@e(ua$le hello
/nder /NI8, suffi@es are i&poran .i.e., .( versus .o0. !hey ell he (o&piler wha ype
of file hey are, i.e. a % progra& file versus an o$-e( &odule.
3 22 4++,+ 567,+ %+ 48567
!his links wo separaely (o&piled &odules ino an e@e(ua$le na&ed fubar.
1-!!
Introduction to Programming in C
'he compiling process 33 overvie,
C P7+976: %% 4++,2
3 22 %2 4++,2
211 %% C 17.17+2.''+7
!6;)/.' <%)*7.2(*=.'> 7.:+=.' 2+::.;('
4++,E
C O1(*:*?.7
@+1(*+;6/A
22+: %% C C+:1*/.7
2+:1*/. 17+976:
4++,'
4++,+
6' %% 6''.:5/.7
1-!"
Introduction to Programming in C
Compiling process 33 translation phases :*.SI;
9. Physi(al sour(e file (hara(ers are &apped o he sour(e (hara(er se .in(luding new"
line (hara(ers and end"of"file indi(aors0 if ne(essary. Trigraph sequences are
repla(ed $y (orresponding single"(hara(er inernal represenaions.
;. =a(h insan(e of a new"line (hara(er and an i&&ediaely pre(eding $a(kslash
(hara(er .B0 is deleed, splicing physical source lines to form logical source lines.
1. !he sour(e file is de(o&posed ino prepro(essing okens and seOuen(es of whie"
spa(e (hara(ers .in(luding (o&&ens0. A sour(e file shall not end in a partial
prepro(essing oken or (o&&en. =a(h (o&&en is repla(ed $y one spa(e (hara(er.
New"line (hara(ers are reained.
<. Prepro(essing dire(ives are e@e(ued and &a(ro invo(aions are e@panded. A
<*;2/8). prepro(essing dire(ive (auses he na&ed header or sour(e file o $e
pro(essed fro& phase 9 hrough phase < recursively.
3. =a(h sour(e (hara(er se &e&$er and es(ape seOuen(e in (hara(er (onsans and
sring lierals is (onvered o a &e&$er of he e@e(uion (hara(er se.
E. Ad-a(en (hara(er sring lieral okens are (on(aenaed and ad-a(en wide sring
lieral okens are (on(aenaed.
6. #hie"spa(e (hara(ers separaing okens are no longer signifi(an. =a(h
prepro(essing oken is (onvered ino a oken. !he resuling okens are syntactically
and semantically analyMed and ranslaed.
5. All e@ernal o$-e( and fun(ion referen(es are resolved. 7i$rary (o&ponens are
linked o saisfy e@ernal referen(es o fun(ions and o$-e(s not defined in he (urren
ranslaion. All su(h ranslaion oupu is (olle(ed ino a progra& i&age whi(h
(onains infor&aion needed for e@e(uion in is e@e(uion environ&en.

1-!#

Anda mungkin juga menyukai