2000 %!PS-Adobe-2.0 %%Version: 0.1 %%DocumentFonts: (atend) %%Pages: (atend) %%EndComments % % Version 3.3.2 prologue for troff files. % /#copies 1 store /aspectratio 1 def /formsperpage 1 def /landscape false def /linewidth .3 def /magnification 1 def /margin 0 def /orientation 0 def /resolution 720 def /rotation 1 def /xoffset 0 def /yoffset 0 def /roundpage true def /useclippath true def /pagebbox [0 0 612 792] def /R /Times-Roman def /I /Times-Italic def /B /Times-Bold def /BI /Times-BoldItalic def /H /Helvetica def /HI /Helvetica-Oblique def /HB /Helvetica-Bold def /HX /Helvetica-BoldOblique def /CW /Courier def /CO /Courier def /CI /Courier-Oblique def /CB /Courier-Bold def /CX /Courier-BoldOblique def /PA /Palatino-Roman def /PI /Palatino-Italic def /PB /Palatino-Bold def /PX /Palatino-BoldItalic def /Hr /Helvetica-Narrow def /Hi /Helvetica-Narrow-Oblique def /Hb /Helvetica-Narrow-Bold def /Hx /Helvetica-Narrow-BoldOblique def /KR /Bookman-Light def /KI /Bookman-LightItalic def /KB /Bookman-Demi def /KX /Bookman-DemiItalic def /AR /AvantGarde-Book def /AI /AvantGarde-BookOblique def /AB /AvantGarde-Demi def /AX /AvantGarde-DemiOblique def /NR /NewCenturySchlbk-Roman def /NI /NewCenturySchlbk-Italic def /NB /NewCenturySchlbk-Bold def /NX /NewCenturySchlbk-BoldItalic def /ZD /ZapfDingbats def /ZI /ZapfChancery-MediumItalic def /S /S def /S1 /S1 def /GR /Symbol def /inch {72 mul} bind def /min {2 copy gt {exch} if pop} bind def /setup { counttomark 2 idiv {def} repeat pop landscape {/orientation 90 orientation add def} if /scaling 72 resolution div def linewidth setlinewidth 1 setlinecap pagedimensions xcenter ycenter translate orientation rotation mul rotate width 2 div neg height 2 div translate xoffset inch yoffset inch neg translate margin 2 div dup neg translate magnification dup aspectratio mul scale scaling scaling scale addmetrics 0 0 moveto } def /pagedimensions { useclippath userdict /gotpagebbox known not and { /pagebbox [clippath pathbbox newpath] def roundpage currentdict /roundpagebbox known and {roundpagebbox} if } if pagebbox aload pop 4 -1 roll exch 4 1 roll 4 copy landscape {4 2 roll} if sub /width exch def sub /height exch def add 2 div /xcenter exch def add 2 div /ycenter exch def userdict /gotpagebbox true put } def /addmetrics { /Symbol /S null Sdefs cf /Times-Roman /S1 StandardEncoding dup length array copy S1defs cf } def /pagesetup { /page exch def currentdict /pagedict known currentdict page known and { page load pagedict exch get cvx exec } if } def /decodingdefs [ {counttomark 2 idiv {y moveto show} repeat} {neg /y exch def counttomark 2 idiv {y moveto show} repeat} {neg moveto {2 index stringwidth pop sub exch div 0 32 4 -1 roll widthshow} repeat} {neg moveto {spacewidth sub 0.0 32 4 -1 roll widthshow} repeat} {counttomark 2 idiv {y moveto show} repeat} {neg setfunnytext} ] def /setdecoding {/t decodingdefs 3 -1 roll get bind def} bind def /w {neg moveto show} bind def /m {neg dup /y exch def moveto} bind def /done {/lastpage where {pop lastpage} if} def /f { dup /font exch def findfont exch dup /ptsize exch def scaling div dup /size exch def scalefont setfont linewidth ptsize mul scaling 10 mul div setlinewidth /spacewidth ( ) stringwidth pop def } bind def /changefont { /fontheight exch def /fontslant exch def currentfont [ 1 0 fontheight ptsize div fontslant sin mul fontslant cos div fontheight ptsize div 0 0 ] makefont setfont } bind def /sf {f} bind def /cf { dup length 2 idiv /entries exch def /chtab exch def /newencoding exch def /newfont exch def findfont dup length 1 add dict /newdict exch def {1 index /FID ne {newdict 3 1 roll put}{pop pop} ifelse} forall newencoding type /arraytype eq {newdict /Encoding newencoding put} if newdict /Metrics entries dict put newdict /Metrics get begin chtab aload pop 1 1 entries {pop def} for newfont newdict definefont pop end } bind def % % A few arrays used to adjust reference points and character widths in some % of the printer resident fonts. If square roots are too high try changing % the lines describing /radical and /radicalex to, % % /radical [0 -75 550 0] % /radicalex [-50 -75 500 0] % % Move braceleftbt a bit - default PostScript character is off a bit. % /Sdefs [ /bracketlefttp [201 500] /bracketleftbt [201 500] /bracketrighttp [-81 380] /bracketrightbt [-83 380] /braceleftbt [203 490] /bracketrightex [220 -125 500 0] /radical [0 0 550 0] /radicalex [-50 0 500 0] /parenleftex [-20 -170 0 0] /integral [100 -50 500 0] /infinity [10 -75 730 0] ] def /S1defs [ /underscore [0 80 500 0] /endash [7 90 650 0] ] def % % Tries to round clipping path dimensions, as stored in array pagebbox, so they % match one of the known sizes in the papersizes array. Lower left coordinates % are always set to 0. % /roundpagebbox { 7 dict begin /papersizes [8.5 inch 11 inch 14 inch 17 inch] def /mappapersize { /val exch def /slop .5 inch def /diff slop def /j 0 def 0 1 papersizes length 1 sub { /i exch def papersizes i get val sub abs dup diff le {/diff exch def /j i def} {pop} ifelse } for diff slop lt {papersizes j get} {val} ifelse } def pagebbox 0 0 put pagebbox 1 0 put pagebbox dup 2 get mappapersize 2 exch put pagebbox dup 3 get mappapersize 3 exch put end } bind def %%EndProlog %%BeginSetup mark % % Encoding vector and redefinition of findfont for the ISO Latin1 standard. % The 18 characters missing from ROM based fonts on older printers are noted % below. % /ISOLatin1Encoding [ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright /parenleft /parenright /asterisk /plus /comma /minus /period /slash /zero /one /two /three /four /five /six /seven /eight /nine /colon /semicolon /less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron /space /exclamdown /cent /sterling /currency /yen /brokenbar % missing /section /dieresis /copyright /ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree % missing /plusminus % missing /twosuperior % missing /threesuperior % missing /acute /mu % missing /paragraph /periodcentered /cedilla /onesuperior % missing /ordmasculine /guillemotright /onequarter % missing /onehalf % missing /threequarters % missing /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth % missing /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply % missing /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute % missing /Thorn 2000 % missing /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth % missing /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide % missing /oslash /ugrave /uacute /ucircumflex /udieresis /yacute % missing /thorn % missing /ydieresis ] def /NewFontDirectory FontDirectory maxlength dict def % % Apparently no guarantee findfont is defined in systemdict so the obvious % % systemdict /findfont get exec % % can generate an error. So far the only exception is a VT600 (version 48.0). % userdict /@RealFindfont known not { userdict begin /@RealFindfont systemdict begin /findfont load end def end } if /findfont { dup NewFontDirectory exch known not { dup %dup systemdict /findfont get exec % not always in systemdict dup userdict /@RealFindfont get exec dup /Encoding get StandardEncoding eq { dup length dict begin {1 index /FID ne {def}{pop pop} ifelse} forall /Encoding ISOLatin1Encoding def currentdict end /DummyFontName exch definefont } if NewFontDirectory 3 1 roll put } if NewFontDirectory exch get } bind def %%Patch from lp %%EndPatch from lp setup %%EndSetup %%Page: 1 1 /saveobj save def mark 1 pagesetup 12 /Helvetica f (Programming) 2075 1920 w (in) 2830 1920 w (C) 2957 1920 w 12 /LucidaSansUnicode20 f (\023) 3077 1920 w 12 /Helvetica f (A) 3171 1920 w (Tutorial) 3285 1920 w 10 /Times-Roman f (Brian W. Kernighan) 2474 2160 w 10 /Times-Italic f (Bell Laboratories, Murray Hill, N. J.) 2139 2400 w 10 /Helvetica f (1. Introduction) 720 3192 w 10 /Times-Roman f (C) 970 3348 w (is) 1069 3348 w (a) 1168 3348 w (computer) 1244 3348 w (language) 1653 3348 w (available) 2045 3348 w (on) 2437 3348 w (the) 2569 3348 w 8 /Times-Roman f (GCOS) 2718 3348 w 10 /Times-Roman f (and) 2965 3348 w 8 /Times-Roman f (UNIX) 3136 3348 w 10 /Times-Roman f (operating) 3368 3348 w (systems) 3777 3348 w (at) 4126 3348 w (Murray) 4231 3348 w (Hill) 4563 3348 w (and) 4752 3348 w (\(in) 4929 3348 w (preliminary) 720 3468 w (form\)) 1218 3468 w (on) 1477 3468 w (OS/360) 1609 3468 w (at) 1947 3468 w (Holmdel.) 2051 3468 w (C) 2483 3468 w (lets) 2582 3468 w (you) 2753 3468 w (write) 2935 3468 w (your) 3172 3468 w (programs) 3387 3468 w (clearly) 3796 3468 w (and) 4099 3468 w (simply) 4275 3468 w 10 /S f (_) 4580 3468 w 10 /Times-Roman f (it) 4662 3468 w (has) 4749 3468 w (de\255) 4913 3468 w (cent) 720 3588 w (control) 917 3588 w (flow) 1231 3588 w (facilities) 1445 3588 w (so) 1820 3588 w (your) 1940 3588 w (code) 2154 3588 w (can) 2373 3588 w (be) 2543 3588 w (read) 2669 3588 w (straight) 2872 3588 w (down) 3204 3588 w (the) 3458 3588 w (page,) 3612 3588 w (without) 3857 3588 w (labels) 4195 3588 w (or) 4460 3588 w (GOTO's;) 4575 3588 w (it) 4984 3588 w (lets) 720 3708 w (you) 891 3708 w (write) 1072 3708 w (code) 1308 3708 w (that) 1527 3708 w (is) 1708 3708 w (compact) 1806 3708 w (without) 2175 3708 w (being) 2512 3708 w (too) 2765 3708 w (cryptic;) 2924 3708 w (it) 3260 3708 w (encourages) 3347 3708 w (modularity) 3826 3708 w (and) 4296 3708 w (good) 4471 3708 w (program) 4702 3708 w (organization; and it provides good data\255structuring facilities.) 720 3828 w (This memorandum is) 970 3984 w (a) 1846 3984 w (tutorial) 1916 3984 w (to) 2231 3984 w (make) 2335 3984 w (learning) 2577 3984 w (C) 2930 3984 w (as) 3023 3984 w (painless) 3132 3984 w (as) 3480 3984 w (possible.) 3589 3984 w (The) 3993 3984 w (first) 4174 3984 w (part) 4361 3984 w (concentrates) 4542 3984 w (on) 720 4104 w (the) 849 4104 w (central) 1000 4104 w (features) 1300 4104 w (of) 1643 4104 w (C;) 1754 4104 w (the) 1877 4104 w (second) 2027 4104 w (part) 2332 4104 w (discusses) 2515 4104 w (those) 2915 4104 w (parts) 3154 4104 w (of) 3376 4104 w (the) 3487 4104 w (language) 3637 4104 w (which) 4025 4104 w (are) 4297 4104 w (useful) 4446 4104 w (\(usually) 4718 4104 w (for) 720 4224 w (getting) 863 4224 w (more) 1168 4224 w (efficient) 1400 4224 w (and) 1759 4224 w (smaller) 1930 4224 w (code\)) 2251 4224 w (but) 2499 4224 w (which) 2654 4224 w (are) 2925 4224 w (not) 3073 4224 w (necessary) 3228 4224 w (for) 3642 4224 w (the) 3785 4224 w (new) 3934 4224 w (user.) 4127 4224 w (This) 4370 4224 w (is) 4575 4224 w 10 /Times-Italic f (not) 4669 4224 w 10 /Times-Roman f (a) 4825 4224 w (ref\255) 4897 4224 w (erence) 720 4344 w (manual.) 1010 4344 w (Details) 1385 4344 w (and) 1699 4344 w (special) 1874 4344 w (cases) 2182 4344 w (will) 2423 4344 w (be) 2610 4344 w (skipped) 2735 4344 w (ruthlessly,) 3077 4344 w (and) 3521 4344 w (no) 3695 4344 w (attempt) 3825 4344 w (will) 4155 4344 w (be) 4341 4344 w (made) 4465 4344 w (to) 4711 4344 w (cover) 4819 4344 w (every) 720 4464 w (language) 973 4464 w (feature.) 1365 4464 w (The) 1723 4464 w (order) 1910 4464 w (of) 2153 4464 w (presentation) 2269 4464 w (is) 2790 4464 w (hopefully) 2890 4464 w (pedagogical) 3306 4464 w (instead) 3821 4464 w (of) 4137 4464 w (logical.) 4253 4464 w (Users) 4608 4464 w (who) 4868 4464 w (would) 720 4584 w (like) 996 4584 w (the) 1172 4584 w (full) 1320 4584 w (story) 1485 4584 w (should) 1711 4584 w (consult) 2004 4584 w (the) 2319 4584 w 10 /Times-Italic f (C) 2467 4584 w (Reference) 2560 4584 w (Manual) 2984 4584 w 10 /Times-Roman f (by) 3321 4584 w (D.) 3447 4584 w (M. Ritchie [1], which should be read) 3570 4584 w (for) 720 4704 w (details) 863 4704 w (anyway.) 1151 4704 w (Runtime) 1538 4704 w (support) 1910 4704 w (is) 2237 4704 w (described) 2332 4704 w (in) 2742 4704 w ([2]) 2848 4704 w (and) 2992 4704 w ([3];) 3164 4704 w (you) 3336 4704 w (will) 3514 4704 w (have) 3698 4704 w (to) 3914 4704 w (read) 4020 4704 w (one) 4219 4704 w (of) 4391 4704 w (these) 4502 4704 w (to) 4735 4704 w (learn) 4841 4704 w (how to compile and run a C program.) 720 4824 w (We) 970 4980 w (will) 1136 4980 w (assume) 1320 4980 w (that) 1642 4980 w (you) 1820 4980 w (are) 1998 4980 w (familiar) 2147 4980 w (with) 2491 4980 w (the) 2697 4980 w (mysteries) 2848 4980 w (of) 3260 4980 w (creating) 3372 4980 w (files,) 3722 4980 w (text) 3948 4980 w (editing,) 4127 4980 w (and) 4459 4980 w (the) 4632 4980 w (like) 4783 4980 w (in) 4962 4980 w (the operating system you run on, and that you have programmed in some language before.) 720 5100 w 10 /Helvetica f (2. A Simple C Program) 720 5340 w (main\( ) 1080 5546 w (\)) 1365 5546 w ({) 1433 5546 w (printf\("hello,) 1440 5666 w (world"\);) 2007 5666 w (}) 1080 5786 w 10 /Times-Roman f (A) 970 5992 w (C) 1069 5992 w (program) 1163 5992 w (consists) 1528 5992 w (of) 1872 5992 w (one) 1982 5992 w (or) 2153 5992 w (more) 2263 5992 w 10 /Times-Italic f (functions,) 2495 5992 w 10 /Times-Roman f (which) 2914 5992 w (are) 3185 5992 w (similar) 3334 5992 w (to) 3640 5992 w (the) 3746 5992 w (functions) 3896 5992 w (and) 4296 5992 w (subroutines) 4468 5992 w (of) 4957 5992 w (a) 720 6112 w (Fortran) 798 6112 w (program) 1126 6112 w (or) 1498 6112 w (the) 1615 6112 w (procedures) 1771 6112 w (of) 2242 6112 w (PL/I,) 2359 6112 w (and) 2596 6112 w (perhaps) 2773 6112 w (some) 3116 6112 w (external) 3360 6112 w (data) 3714 6112 w (definitions.) 3913 6112 w 10 /Helvetica f (main) 4430 6112 w 10 /Times-Roman f (is) 4680 6112 w (such) 4780 6112 w (a) 4996 6112 w (function,) 720 6232 w (and) 1106 6232 w (in) 1279 6232 w (fact) 1386 6232 w (all) 1564 6232 w (C) 1693 6232 w (programs) 1789 6232 w (must) 2195 6232 w (have) 2419 6232 w (a) 2636 6232 w 10 /Helvetica f (main) 2712 6232 w 16 /Helvetica f (.) 2929 6232 w 10 /Times-Roman f (Execution) 3028 6232 w (of) 3462 6232 w (the) 3574 6232 w (program) 3725 6232 w (begins) 4092 6232 w (at) 4382 6232 w (the) 4483 6232 w (first) 4634 6232 w (state\255) 4824 6232 w (ment) 720 6352 w 2000 (of) 953 6352 w 10 /Helvetica f (main) 1072 6352 w 16 /Helvetica f (.) 1289 6352 w 10 /Helvetica f (main) 1398 6352 w 10 /Times-Roman f (will) 1648 6352 w (usually) 1837 6352 w (invoke) 2159 6352 w (other) 2464 6352 w (functions) 2701 6352 w (to) 3105 6352 w (perform) 3215 6352 w (its) 3568 6352 w (job,) 3695 6352 w (some) 3880 6352 w (coming) 4123 6352 w (from) 4455 6352 w (the) 4681 6352 w (same) 4835 6352 w (program, and others from libraries.) 720 6472 w (One) 970 6628 w (method) 1168 6628 w (of) 1500 6628 w (communicating) 1615 6628 w (data) 2269 6628 w (between) 2467 6628 w (functions) 2831 6628 w (is) 3235 6628 w (by) 3334 6628 w (arguments.) 3466 6628 w (The) 3965 6628 w (parentheses) 4153 6628 w (following) 4651 6628 w (the) 720 6748 w (function) 878 6748 w (name) 1247 6748 w (surround) 1499 6748 w (the) 1890 6748 w (argument) 2048 6748 w (list;) 2461 6748 w (here) 2648 6748 w 10 /Helvetica f (main) 2858 6748 w 10 /Times-Roman f (is) 3110 6748 w (a) 3212 6748 w (function) 3291 6748 w (of) 3659 6748 w (no) 3777 6748 w (arguments,) 3912 6748 w (indicated) 4388 6748 w (by) 4789 6748 w (\( \).) 4924 6748 w (The) 720 6868 w ({}) 908 6868 w (enclose) 1037 6868 w (the) 1369 6868 w (statements) 1525 6868 w (of) 1981 6868 w (the) 2098 6868 w (function.) 2254 6868 w (Individual) 2671 6868 w (statements) 3116 6868 w (end) 3572 6868 w (with) 3750 6868 w (a) 3962 6868 w (semicolon) 4040 6868 w (but) 4485 6868 w (are) 4647 6868 w (other\255) 4802 6868 w (wise free\255format.) 720 6988 w 10 /Helvetica f (printf) 970 7144 w 10 /Times-Roman f (is) 1220 7144 w (a) 1314 7144 w (library) 1385 7144 w (function) 1678 7144 w (which) 2038 7144 w (will) 2309 7144 w (format) 2492 7144 w (and) 2785 7144 w (print) 2956 7144 w (output) 3172 7144 w (on) 3455 7144 w (the) 3582 7144 w (terminal) 3731 7144 w (\(unless) 4091 7144 w (some) 4402 7144 w (other) 4641 7144 w (des\255) 4874 7144 w (tination is specified\).) 720 7264 w (In this) 1611 7264 w (case it prints) 1914 7264 w cleartomark showpage saveobj restore %%EndPage: 1 1 %%Page: 2 2 /saveobj save def mark 2 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 2 \255) 2977 360 w 10 /Helvetica f (hello,) 1080 890 w (world) 1355 890 w 10 /Times-Roman f (A) 720 1060 w (function) 818 1060 w (is) 1177 1060 w (invoked) 1271 1060 w (by) 1620 1060 w (naming) 1747 1060 w (it,) 2074 1060 w (followed) 2182 1060 w (by) 2564 1060 w (a) 2691 1060 w (list) 2762 1060 w (of) 2912 1060 w (arguments) 3022 1060 w (in) 3465 1060 w (parentheses.) 3570 1060 w (There) 4112 1060 w (is) 4371 1060 w (no) 4465 1060 w 8 /Times-Roman f (CALL) 4587 1060 w 10 /Times-Roman f (state\255) 4824 1060 w (ment as in Fortran or) 720 1180 w 8 /Times-Roman f (PL/I.) 1578 1180 w 10 /Helvetica f (3. A Working C Program; Variables; Types and Type Declarations) 720 1420 w 10 /Times-Roman f (Here's a bigger program that adds three integers and prints their sum.) 970 1576 w 10 /Helvetica f (main\( ) 1080 1746 w (\)) 1365 1746 w ({) 1433 1746 w (int) 1440 1866 w (a,) 1581 1866 w (b,) 1700 1866 w (c,) 1819 1866 w (sum;) 1932 1866 w (a) 1440 1986 w (=) 1531 1986 w (1;) 1624 1986 w (b) 1778 1986 w (=) 1869 1986 w (2;) 1962 1986 w (c) 2116 1986 w (=) 2201 1986 w (3;) 2294 1986 w (sum) 1440 2106 w (=) 1664 2106 w (a) 1757 2106 w (+) 1848 2106 w (b) 1941 2106 w (+) 2032 2106 w (c;) 2125 2106 w (printf\("sum) 1440 2226 w (is) 1956 2226 w (%d",) 2063 2226 w (sum\);) 2307 2226 w (}) 1080 2346 w 10 /Times-Roman f (Arithmetic) 970 2552 w (and) 1444 2552 w (the) 1629 2552 w (assignment) 1792 2552 w (statements) 2283 2552 w (are) 2746 2552 w (much) 2908 2552 w (the) 3171 2552 w (same) 3334 2552 w (as) 3580 2552 w (in) 3705 2552 w (Fortran) 3825 2552 w (\(except) 4161 2552 w (for) 4496 2552 w (the) 4654 2552 w (semi\255) 4818 2552 w (colons\)) 720 2672 w (or) 1040 2672 w 8 /Times-Roman f (PL/I.) 1144 2672 w 10 /Times-Roman f (The) 1357 2672 w (format) 1538 2672 w (of) 1830 2672 w (C) 1939 2672 w (programs) 2032 2672 w (is) 2435 2672 w (quite) 2528 2672 w (free.) 2754 2672 w (We) 2984 2672 w (can) 3148 2672 w (put) 3312 2672 w (several) 3466 2672 w (statements) 3774 2672 w (on) 4222 2672 w (a) 4348 2672 w (line) 4418 2672 w (if we want,) 4594 2672 w (or) 720 2792 w (we) 833 2792 w (can) 980 2792 w (split) 1149 2792 w (a) 1353 2792 w (statement) 1428 2792 w (among) 1842 2792 w (several) 2145 2792 w (lines) 2458 2792 w (if) 2678 2792 w (it) 2770 2792 w (seems) 2857 2792 w (desirable.) 3132 2792 w (The) 3548 2792 w (split) 3734 2792 w (may) 3938 2792 w (be) 4141 2792 w (between) 4266 2792 w (any) 4629 2792 w (of) 4804 2792 w (the) 4918 2792 w (operators) 720 2912 w (or) 1122 2912 w (variables,) 1236 2912 w (but) 1652 2912 w 10 /Times-Italic f (not) 1811 2912 w 10 /Times-Roman f (in) 1970 2912 w (the) 2079 2912 w (middle) 2232 2912 w (of) 2541 2912 w (a) 2655 2912 w (name) 2730 2912 w (or) 2977 2912 w (operator.) 3091 2912 w (As) 3504 2912 w (a) 3646 2912 w (matter) 3721 2912 w (of) 4007 2912 w (style,) 4121 2912 w (spaces,) 4365 2912 w (tabs,) 4680 2912 w (and) 4896 2912 w (newlines should be used freely to enhance readability.) 720 3032 w (C has four fundamental) 970 3188 w 10 /Times-Italic f (types) 1935 3188 w 10 /Times-Roman f (of variables:) 2165 3188 w 10 /Helvetica f (int) 1080 3368 w 10 /Times-Roman f (integer \(PDP\25511: 16 bits; H6070: 36 bits; IBM360: 32 bits\)) 1440 3368 w 10 /Helvetica f (char) 1080 3488 w 10 /Times-Roman f (one byte character \(PDP\25511, IBM360: 8 bits; H6070: 9 bits\)) 1440 3488 w 10 /Helvetica f (float) 1080 3608 w 10 /Times-Roman f (single\255precision floating point) 1440 3608 w 10 /Helvetica f (double) 1080 3728 w 10 /Times-Roman f (double\255precision floating point) 1440 3728 w (There) 720 3908 w (are) 983 3908 w (also) 1135 3908 w 10 /Times-Italic f (arrays) 1328 3908 w 10 /Times-Roman f (and) 1621 3908 w 10 /Times-Italic f (structures) 1797 3908 w 10 /Times-Roman f (of) 2229 3908 w (these) 2344 3908 w (basic) 2581 3908 w (types,) 2818 3908 w 10 /Times-Italic f (pointers) 3086 3908 w 10 /Times-Roman f (to) 3446 3908 w (them) 3556 3908 w (and) 3788 3908 w 10 /Times-Italic f (functions) 3964 3908 w 10 /Times-Roman f (that) 4363 3908 w (return) 4545 3908 w (them,) 4815 3908 w (all of which we will meet shortly.) 720 4028 w 10 /Times-Italic f (All) 970 4184 w 10 /Times-Roman f (variables) 1123 4184 w (in) 1519 4184 w (a) 1633 4184 w (C) 1713 4184 w (program) 1816 4184 w (must) 2190 4184 w (be) 2421 4184 w (declared,) 2551 4184 w (although) 2949 4184 w (this) 3335 4184 w (can) 3516 4184 w (sometimes) 3690 4184 w (be) 4154 4184 w (done) 4284 4184 w (implicitly) 4514 4184 w (by) 4940 4184 w (context.) 720 4304 w (Declarations must precede executable statements.) 1089 4304 w (The declaration) 3120 4304 w 10 /Helvetica f (int) 1080 4474 w (a,) 1221 4474 w (b,) 1340 4474 w (c,) 1459 4474 w (sum;) 1572 4474 w 10 /Times-Roman f (declares) 720 4644 w 10 /Helvetica f (a, b, c,) 1074 4644 w 10 /Times-Roman f (and) 1401 4644 w 10 /Helvetica f (sum) 1573 4644 w 10 /Times-Roman f (to be integers.) 1787 4644 w (Variable) 970 4800 w (names) 1342 4800 w (have) 1626 4800 w (one) 1843 4800 w (to) 2016 4800 w (eight) 2123 4800 w (characters,) 2352 4800 w (chosen) 2809 4800 w (from) 3115 4800 w (A\255Z,) 3338 4800 w (a\255z,) 3558 4800 w (0\2559,) 3733 4800 w (and) 3920 4800 w 10 /S f (_) 4094 4800 w 10 /Times-Roman f (,) 4144 4800 w (and) 4199 4800 w (start) 4373 4800 w (with) 4575 4800 w (a) 4783 4800 w (non\255) 4857 4800 w (digit.) 720 4920 w (Stylistically,) 995 4920 w (it's) 1540 4920 w (much) 1709 4920 w (better) 1972 4920 w (to) 2240 4920 w (use) 2359 4920 w (only) 2533 4920 w (a) 2752 4920 w (single) 2837 4920 w (case) 3116 4920 w (and) 3327 4920 w (give) 3511 4920 w (functions) 3723 4920 w (and) 4135 4920 w (external) 4319 4920 w (variables) 4680 4920 w (names) 720 5 2000 040 w (that) 1002 5040 w (are) 1179 5040 w (unique) 1327 5040 w (in) 1626 5040 w (the) 1731 5040 w (first) 1880 5040 w (six) 2068 5040 w (characters.) 2212 5040 w (\(Function) 2692 5040 w (and) 3108 5040 w (external) 3279 5040 w (variable) 3627 5040 w (names) 3975 5040 w (are) 4258 5040 w (used) 4407 5040 w (by) 4618 5040 w (various) 4746 5040 w (assemblers,) 720 5160 w (some) 1219 5160 w (of) 1466 5160 w (which) 1585 5160 w (are) 1865 5160 w (limited) 2022 5160 w (in) 2342 5160 w (the) 2456 5160 w (size) 2614 5160 w (and) 2805 5160 w (case) 2985 5160 w (of) 3192 5160 w (identifiers) 3311 5160 w (they) 3752 5160 w (can) 3959 5160 w (handle.\)) 4132 5160 w (Furthermore,) 4516 5160 w (keywords and library functions may only be recognized in one case.) 720 5280 w 10 /Helvetica f (4. Constants) 720 5520 w 10 /Times-Roman f (We) 970 5676 w (have) 1134 5676 w (already) 1348 5676 w (seen) 1668 5676 w (decimal) 1872 5676 w (integer) 2215 5676 w (constants) 2519 5676 w (in) 2918 5676 w (the) 3023 5676 w (previous) 3172 5676 w (example) 3543 5676 w 10 /S f (_) 3908 5676 w 10 /Times-Roman f (1,) 3985 5676 w (2,) 4087 5676 w (and) 4189 5676 w (3.) 4360 5676 w (Since) 4487 5676 w (C) 4736 5676 w (is) 4830 5676 w (of\255) 4924 5676 w (ten) 720 5796 w (used) 881 5796 w (for) 1103 5796 w (system) 1258 5796 w (programming) 1575 5796 w (and) 2158 5796 w (bit\255manipulation,) 2341 5796 w (octal) 3072 5796 w (numbers) 3305 5796 w (are) 3688 5796 w (an) 3848 5796 w (important) 3981 5796 w (part) 4409 5796 w (of) 4603 5796 w (the) 4725 5796 w (lan\255) 4885 5796 w (guage.) 720 5916 w (In) 1035 5916 w (C,) 1145 5916 w (any) 1264 5916 w (number) 1435 5916 w (that) 1767 5916 w (begins) 1944 5916 w (with) 2232 5916 w (0) 2437 5916 w (\(zero!\)) 2514 5916 w (is) 2836 5916 w (an) 2930 5916 w (octal) 3051 5916 w (integer) 3272 5916 w (\(and) 3577 5916 w (hence) 3782 5916 w (can't) 4042 5916 w (have) 4269 5916 w (any) 4485 5916 w (8's) 4657 5916 w (or) 4807 5916 w (9's) 4918 5916 w (in it\).) 720 6036 w (Thus 0777 is an octal constant, with decimal value 511.) 987 6036 w (A) 970 6192 w (``character'') 1072 6192 w (is) 1598 6192 w (one) 1695 6192 w (byte) 1869 6192 w (\(an) 2071 6192 w (inherently) 2228 6192 w (machine\255dependent) 2664 6192 w (concept\).) 3476 6192 w (Most) 3900 6192 w (often) 4137 6192 w (this) 4373 6192 w (is) 4549 6192 w (expressed) 4647 6192 w (as) 720 6312 w (a) 831 6312 w 10 /Times-Italic f (character) 903 6312 w (constant,) 1318 6312 w 10 /Times-Roman f (which) 1709 6312 w (is) 1980 6312 w (one) 2074 6312 w (character) 2245 6312 w (enclosed) 2636 6312 w (in) 3012 6312 w (single) 3117 6312 w (quotes.) 3383 6312 w (However,) 3721 6312 w (it) 4138 6312 w (may) 4221 6312 w (be) 4420 6312 w (any) 4541 6312 w (quantity) 4712 6312 w (that fits in a byte, as in) 720 6432 w 10 /Helvetica f (flags) 1656 6432 w 10 /Times-Roman f (below:) 1893 6432 w 10 /Helvetica f (char) 1080 6602 w (quest,) 1310 6602 w (newline,) 1619 6602 w (flags;) 2022 6602 w (quest) 1080 6722 w (=) 1361 6722 w 10 /S f (\242) 1454 6722 w 10 /Helvetica f (?) 1479 6722 w 10 /S f (\242) 1535 6722 w 10 /Helvetica f (;) 1560 6722 w (newline) 1080 6842 w (=) 1455 6842 w 10 /S f (\242) 1548 6842 w 10 /Helvetica f (\\n) 1573 6842 w 10 /S f (\242) 1657 6842 w 10 /Helvetica f (;) 1682 6842 w (flags) 1080 6962 w (=) 1327 6962 w (077;) 1420 6962 w cleartomark showpage saveobj restore %%EndPage: 2 2 %%Page: 3 3 /saveobj save def mark 3 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 3 \255) 2977 360 w (The) 970 876 w (sequence) 1155 876 w (`\\n') 1550 876 w (is) 1724 876 w (C) 1821 876 w (notation) 1918 876 w (for) 2276 876 w (``newline) 2423 876 w (character'',) 2836 876 w (which,) 3322 876 w (when) 3622 876 w (printed,) 3869 876 w (skips) 4208 876 w (the) 4445 876 w (terminal) 4598 876 w (to) 4962 876 w (the) 720 996 w (beginning) 874 996 w (of) 1306 996 w (the) 1421 996 w (next) 1575 996 w (line.) 1779 996 w (Notice) 2011 996 w (that) 2309 996 w (`\\n') 2491 996 w (represents) 2667 996 w (only) 3103 996 w (a) 3313 996 w (single) 3389 996 w (character.) 3660 996 w (There) 4106 996 w (are) 4370 996 w (several) 4522 996 w (other) 4835 996 w (``escapes'') 720 1116 w (like) 1188 1116 w (`\\n') 1370 1116 w (for) 1571 1116 w (representing) 1720 1116 w (hard\255to\255get) 2246 1116 w (or) 2722 1116 w (invisible) 2838 1116 w (characters,) 3216 1116 w (such) 3677 1116 w (as) 3893 1116 w (`\\t') 4009 1116 w (for) 4164 1116 w (tab,) 4313 1116 w (`\\b') 4493 1116 w (for) 4670 1116 w (back\255) 4819 1116 w (space, `\\0' for end of file, and `\\\\' for the backslash itself.) 720 1236 w 10 /Helvetica f (float) 970 1392 w 10 /Times-Roman f (and) 1185 1392 w 10 /Helvetica f (double) 1357 1392 w 10 /Times-Roman f (constants are discussed in section 26.) 1684 1392 w 10 /Helvetica f (5. Simple I/O ) 720 1632 w 10 /S f (_) 1328 1632 w 10 /Helvetica f (getchar, putchar, printf) 1406 1632 w (main\() 1080 1838 w (\)) 1365 1838 w ({) 1433 1838 w (char) 1440 1958 w (c;) 1670 1958 w (c) 1440 2078 w (=) 1525 2078 w (getchar\( ) 1618 2078 w (\);) 2021 2078 w (putchar\(c\);) 1440 2198 w (}) 1080 2318 w (getchar) 970 2524 w 10 /Times-Roman f (and) 1339 2524 w 10 /Helvetica f (putchar) 1520 2524 w 10 /Times-Roman f (are) 1889 2524 w (the) 2044 2524 w (basic) 2200 2524 w (I/O) 2439 2524 w (library) 2606 2524 w (functions) 2906 2524 w (in) 3312 2524 w (C.) 3424 2524 w 10 /Helvetica f (getchar) 3581 2524 w 10 /Times-Roman f (fetches) 3951 2524 w (one) 4268 2524 w (character) 4447 2524 w (from) 4846 2524 w (the) 720 2644 w (standard) 871 2644 w (input) 1238 2644 w (\(usually) 1473 2644 w (the) 1824 2644 w (terminal\)) 1975 2644 w (each) 2369 2644 w (time) 2579 2644 w (it) 2785 2644 w (is) 2869 2644 w (called,) 2964 2644 w (and) 3255 2644 w (returns) 3427 2644 w (that) 3732 2644 w (character) 3910 2644 w (as) 4302 2644 w (the) 4413 2644 w (value) 4563 2644 w (of) 4807 2644 w (the) 4918 2644 w (function.) 720 2764 w (When) 1139 2764 w (it) 1413 2764 w (reaches) 1505 2764 w (the) 1839 2764 w (end) 1997 2764 w (of) 2177 2764 w (whatever) 2296 2764 w (file) 2697 2764 w (it) 2866 2764 w (is) 2958 2764 w (reading,) 3061 2764 w (thereafter) 3421 2764 w (it) 3838 2764 w (returns) 3930 2764 w (the) 4243 2764 w (character) 4402 2764 w (repre\255) 4803 2764 w (sented by `\\0' \(ascii) 720 2884 w 8 /Times-Roman f (NUL,) 1530 2884 w 10 /Times-Roman f (which has value zero\).) 1740 2884 w (We will see how to use this very shortly.) 2687 2884 w 10 /Helvetica f (putchar) 970 3040 w 10 /Times-Roman f (puts one character out on the standard output \(usually the terminal\) each time) 1330 3040 w (it) 4445 3040 w (is) 4527 3040 w (called.) 4620 3040 w (So) 4934 3040 w (the) 720 3160 w (program) 873 3160 w (above) 1242 3160 w (reads) 1511 3160 w (one) 1752 3160 w (character) 1926 3160 w (and) 2320 3160 w (writes) 2494 3160 w (it) 2768 3160 w (back) 2854 3160 w (out.) 3072 3160 w (By) 3280 3160 w (itself,) 3427 3160 w (this) 3682 3160 w (isn't) 3857 3160 w (very) 4065 3160 w (interesting,) 4272 3160 w (but) 4749 3160 w (ob\255) 4907 3160 w (serve) 720 3280 w (that) 956 3280 w (if) 1132 3280 w (we) 1220 3280 w (put) 1363 3280 w (a) 1518 3280 w (loop) 1589 3280 w (around) 1794 3280 w (this,) 2098 3280 w (and) 2295 3280 w (add) 2466 3280 w (a) 2637 3280 w (test) 2708 3280 w (for) 2874 3280 w (end) 3017 3280 w (of) 3188 3280 w (file,) 3298 3280 w (we) 3483 3280 w (have) 3626 3280 w (a) 3841 3280 w (complete) 3912 3280 w (program) 4305 3280 w (for) 4670 3280 w (copy\255) 4813 3280 w (ing one file to another.) 720 3400 w 10 /Helvetica f (printf) 970 3556 w 10 /Times-Roman f (is) 1228 3556 w (a) 1330 3556 w (more) 1409 3556 w (complicated) 1649 3556 w (function) 2172 3556 w (for) 2540 3556 w (producing) 2691 3556 w (formatted) 3131 3556 w (output.) 3554 3556 w (We) 389 2000 5 3556 w (will) 4068 3556 w (talk) 4260 3556 w (about) 4446 3556 w (only) 4704 3556 w (the) 4918 3556 w (simplest) 720 3676 w (use) 1080 3676 w (of) 1239 3676 w (it.) 1348 3676 w (Basically,) 1480 3676 w 10 /Helvetica f (printf) 1906 3676 w 10 /Times-Roman f (uses) 2155 3676 w (its) 2353 3676 w (first) 2474 3676 w (argument) 2661 3676 w (as) 3064 3676 w (formatting) 3173 3676 w (information,) 3621 3676 w (and) 4144 3676 w (any) 4314 3676 w (successive ar\255) 4484 3676 w (guments as variables to be output.) 720 3796 w (Thus) 2130 3796 w 10 /Helvetica f (printf) 1080 3966 w (\("hello,) 1338 3966 w (world\\n"\);) 1682 3966 w 10 /Times-Roman f (is) 720 4136 w (the) 813 4136 w (simplest) 961 4136 w (use) 1321 4136 w 10 /S f (_) 1480 4136 w 10 /Times-Roman f (the) 1556 4136 w (string) 1704 4136 w (``hello,) 1959 4136 w (world\\n'') 2277 4136 w (is) 2681 4136 w (printed) 2775 4136 w (out.) 3085 4136 w (No) 3290 4136 w (formatting) 3439 4136 w (information,) 3888 4136 w (no) 4412 4136 w (variables,) 4539 4136 w (so) 4951 4136 w (the) 720 4256 w (string) 874 4256 w (is) 1134 4256 w (dumped) 1233 4256 w (out) 1587 4256 w (verbatim.) 1747 4256 w (The) 2184 4256 w (newline) 2371 4256 w (is) 2719 4256 w (necessary) 2818 4256 w (to) 3237 4256 w (put) 3347 4256 w (this) 3507 4256 w (out) 3684 4256 w (on) 3844 4256 w (a) 3976 4256 w (line) 4051 4256 w (by) 4232 4256 w (itself.) 4363 4256 w (\(The) 4644 4256 w (con\255) 4863 4256 w (struction) 720 4376 w 10 /Helvetica f ("hello,) 1080 4546 w (world\\n") 1391 4546 w 10 /Times-Roman f (is really an array of) 720 4716 w 10 /Helvetica f (chars) 1523 4716 w 16 /Helvetica f (.) 1768 4716 w 10 /Times-Roman f (More about this shortly.\)) 1863 4716 w (More complicated, if) 970 4872 w 10 /Helvetica f (sum) 1838 4872 w 10 /Times-Roman f (is 6,) 2052 4872 w 10 /Helvetica f (printf) 1080 5042 w (\("sum) 1338 5042 w (is) 1631 5042 w (%d\\n",) 1738 5042 w (sum\);) 2066 5042 w 10 /Times-Roman f (prints) 720 5212 w 10 /Helvetica f (sum) 1080 5382 w (is) 1304 5382 w (6) 1411 5382 w 10 /Times-Roman f (Within) 720 5552 w (the) 1024 5552 w (first) 1172 5552 w (argument) 1359 5552 w (of) 1763 5552 w 10 /Helvetica f (printf,) 1876 5552 w 10 /Times-Roman f (the) 2154 5552 w (characters) 2303 5552 w (``%d'') 2733 5552 w (signify) 3025 5552 w (that) 3330 5552 w (the) 3507 5552 w (next) 3656 5552 w (argument) 3855 5552 w (in) 4259 5552 w (the) 4364 5552 w (argument) 4513 5552 w (list) 4917 5552 w (is to be printed as a base 10 number.) 720 5672 w (Other useful formatting commands are ``%c'' to print out a single character, ``%s'' to print out) 970 5828 w (an) 4793 5828 w (en\255) 4913 5828 w (tire string, and ``%o'' to print a number as octal instead of decimal \(no leading zero\).) 720 5948 w (For example,) 4171 5948 w 10 /Helvetica f (n) 1080 6118 w (=) 1171 6118 w (511;) 1264 6118 w (printf) 1080 6238 w (\("What) 1338 6238 w (is) 1676 6238 w (the) 1783 6238 w (value) 1958 6238 w (of) 2233 6238 w (%d) 2352 6238 w (in) 2532 6238 w (octal?",) 2645 6238 w (n\);) 3012 6238 w (printf) 1080 6358 w (\(") 1338 6358 w (%s!) 1477 6358 w (%d) 1679 6358 w (decimal) 1859 6358 w (is) 2239 6358 w (%o) 2346 6358 w (octal\\n",) 2526 6358 w ("Right",) 2921 6358 w (n,) 3290 6358 w (n\);) 3409 6358 w 10 /Times-Roman f (prints) 720 6528 w 10 /Helvetica f (What) 1080 6698 w (is) 1349 6698 w (the) 1456 6698 w (value) 1631 6698 w (of) 1906 6698 w (511) 2025 6698 w (in) 2228 6698 w (octal?) 2341 6698 w (Right!) 2679 6698 w (511) 2976 6698 w (decimal) 3179 6698 w (is) 3559 6698 w (777) 3666 6698 w (octal) 3869 6698 w 10 /Times-Roman f (Notice that there is no newline at the end of the first) 720 6868 w (output) 2823 6868 w (line.) 3105 6868 w (Successive) 3331 6868 w (calls) 3795 6868 w (to) 4004 6868 w 10 /Helvetica f (printf) 4111 6868 w 10 /Times-Roman f (\(and/or) 4360 6868 w 10 /Helvetica f (putchar,) 4677 6868 w 10 /Times-Roman f (for) 720 6988 w (that) 866 6988 w (matter\)) 1046 6988 w (simply) 1364 6988 w (put) 1667 6988 w (out) 1825 6988 w (characters.) 1983 6988 w (No) 2466 6988 w (newlines) 2618 6988 w (are) 3003 6988 w (printed) 3154 6988 w (unless) 3467 6988 w (you) 3747 6988 w (ask) 3927 6988 w (for) 4089 6988 w (them.) 4234 6988 w (Similarly,) 4513 6988 w (on) 4940 6988 w (input,) 720 7108 w (characters) 978 7108 w (are) 1408 7108 w (read) 1556 7108 w (one) 1754 7108 w (at) 1925 7108 w (a) 2024 7108 w (time) 2095 7108 w (as) 2300 7108 w (you) 2410 7108 w (ask) 2587 7108 w (for) 2748 7108 w (them.) 2892 7108 w (Each) 3170 7108 w (line) 3397 7108 w (is) 3575 7108 w (generally) 3670 7108 w (terminated) 4069 7108 w (by) 4524 7108 w (a) 4652 7108 w (newline) 4724 7108 w (\(\\n\), but there is otherwise no concept of record.) 720 7228 w cleartomark showpage saveobj restore %%EndPage: 3 3 %%Page: 4 4 /saveobj save def mark 4 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 4 \255) 2977 360 w 10 /Helvetica f (6. If; relational operators; compound statements) 720 840 w 10 /Times-Roman f (The basic conditional\255testing statement in C is the) 970 996 w 10 /Helvetica f (if) 3000 996 w 10 /Times-Roman f (statement:) 3075 996 w 10 /Helvetica f (c) 1080 1166 w (=) 1165 1166 w (getchar\() 1258 1166 w (\);) 1661 1166 w (if\() 1080 1286 w (c) 1198 1286 w 10 /Times-Roman f (==) 1283 1286 w 10 /S f (\242) 1430 1286 w 10 /Helvetica f (?) 1455 1286 w 10 /S f (\242) 1511 1286 w 10 /Helvetica f (\)) 1571 1286 w (printf\("why) 1440 1406 w (did) 1945 1406 w (you) 2114 1406 w (type) 2311 1406 w (a) 2536 1406 w (question) 2627 1406 w (mark?\\n"\);) 3042 1406 w 10 /Times-Roman f (The simplest form of) 720 1576 w 10 /Helvetica f (if) 1589 1576 w 10 /Times-Roman f (is) 1664 1576 w 10 /Helvetica f (if) 1080 1746 w (\(expression\)) 1165 1746 w (statement) 1751 1746 w 10 /Times-Roman f (The) 970 1952 w (condition) 1157 1952 w (to) 1567 1952 w (be) 1677 1952 w (tested) 1803 1952 w (is) 2068 1952 w (any) 2167 1952 w (expression) 2343 1952 w (enclosed) 2802 1952 w (in) 3183 1952 w (parentheses.) 3293 1952 w (It) 3840 1952 w (is) 3934 1952 w (followed) 4034 1952 w (by) 4422 1952 w (a) 4555 1952 w (statement.) 4632 1952 w (The) 720 2072 w (expression) 913 2072 w (is) 1378 2072 w (evaluated,) 1483 2072 w (and) 1928 2072 w (if) 2110 2072 w (its) 2209 2072 w (value) 2342 2072 w (is) 2596 2072 w (non\255zero,) 2700 2072 w (the) 3116 2072 w (statement) 3275 2072 w (is) 3695 2072 w (executed.) 3799 2072 w (There's) 4240 2072 w (an) 4581 2072 w (optional) 4712 2072 w 10 /Helvetica f (else) 720 2192 w 10 /Times-Roman f (clause, to be described soon.) 929 2192 w (The character sequence `==') 970 2348 w (is one of the relational operators in C; here is the complete set:) 2157 2348 w (==) 1080 2518 w 10 /Helvetica f (equal) 1440 2518 w (to) 1721 2518 w (\() 1840 2518 w 16 /Helvetica f (.) 1873 2518 w 10 /Helvetica f (EQ) 1918 2518 w 16 /Helvetica f (.) 2063 2518 w 10 /Helvetica f (to) 2143 2518 w (Fortraners\)) 2262 2518 w (!=) 1080 2638 w (not) 1440 2638 w (equal) 1615 2638 w (to) 1896 2638 w (>) 1080 2758 w (greater) 1440 2758 w (than) 1793 2758 w (<) 1080 2878 w (less) 1440 2878 w (than) 1653 2878 w (>=) 1080 2998 w (greater) 1440 2998 w (than) 1793 2998 w (or) 2024 2998 w (equal) 2148 2998 w (to) 2429 2998 w (<=) 1080 3118 w (less) 1440 3118 w (than) 1653 3118 w (or) 1884 3118 w (equal) 2008 3118 w (to) 2289 3118 w 10 /Times-Roman f (The) 970 3324 w (value) 1152 3324 w (of) 1395 3324 w 10 /Helvetica f (``expression) 1508 3324 w (relation) 2067 3324 w (expression'') 2426 3324 w 10 /Times-Roman f (is) 2982 3324 w (1) 3076 3324 w (if) 3153 3324 w (the) 3241 3324 w (relation) 3390 3324 w (is) 3722 3324 w (true,) 3817 3324 w (and) 4025 3324 w (0) 4197 3324 w (if) 4275 3324 w (false.) 4364 3324 w (Don't) 4630 3324 w (for\255) 4891 3324 w (get) 720 3444 w (that) 870 3444 w (the) 1048 3444 w (equality) 1198 3 2000 444 w (test) 1548 3444 w (is) 1715 3444 w (`==';) 1810 3444 w (a) 2044 3444 w (single) 2116 3444 w (`=') 2383 3444 w (causes) 2533 3444 w (an) 2821 3444 w (assignment,) 2943 3444 w (not) 3446 3444 w (a) 3602 3444 w (test,) 3674 3444 w (and) 3866 3444 w (invariably) 4038 3444 w (leads) 4470 3444 w (to) 4702 3444 w (disas\255) 4807 3444 w (ter.) 720 3564 w (Tests can) 970 3720 w (be) 1370 3720 w (combined) 1490 3720 w (with) 1910 3720 w (the) 2114 3720 w (operators) 2262 3720 w 10 /Helvetica f (`&&') 2662 3720 w 8 /Times-Roman f (\(AND\),) 2861 3720 w 10 /Helvetica f (`) 3136 3720 w 10 /S f (|) 3158 3720 w (|) 3194 3720 w 10 /Helvetica f (') 3214 3720 w 8 /Times-Roman f (\(OR\),) 3257 3720 w 10 /Times-Roman f (and) 3467 3720 w 10 /Helvetica f (`!') 3640 3720 w 8 /Times-Roman f (\(NOT\).) 3753 3720 w 10 /Times-Roman f (For) 4041 3720 w (example,) 4206 3720 w (we) 4595 3720 w (can) 4737 3720 w (test) 4901 3720 w (whether a character is blank or tab or newline with) 720 3840 w 10 /Helvetica f (if\() 1080 4010 w (c) 1198 4010 w 10 /Times-Roman f (==) 1248 4010 w 10 /S f (\242) 1360 4010 w (\242) 1420 4010 w (|) 1480 4010 w (|) 1516 4010 w 10 /Helvetica f (c) 1571 4010 w 10 /Times-Roman f (==) 1621 4010 w 10 /S f (\242) 1733 4010 w 10 /Helvetica f (\\t) 1758 4010 w 10 /S f (\242) 1814 4010 w (|) 1874 4010 w (|) 1910 4010 w 10 /Helvetica f (c) 1965 4010 w 10 /Times-Roman f (==) 2015 4010 w 10 /S f (\242) 2127 4010 w 10 /Helvetica f (\\n) 2152 4010 w 10 /S f (\242) 2236 4010 w 10 /Helvetica f (\)) 2296 4010 w 16 /Helvetica f (...) 2364 4010 w 10 /Times-Roman f (C guarantees that) 720 4180 w 10 /Helvetica f (`&&') 1441 4180 w 10 /Times-Roman f (and) 1644 4180 w 10 /Helvetica f (`) 1816 4180 w 10 /S f (|) 1838 4180 w (|) 1874 4180 w 10 /Helvetica f (') 1894 4180 w 10 /Times-Roman f (are evaluated left to right ) 1941 4180 w 10 /S f (_) 2969 4180 w 10 /Times-Roman f (we shall soon see cases where this matters.) 3044 4180 w (One) 970 4336 w (of) 1162 4336 w (the) 1271 4336 w (nice) 1419 4336 w (things) 1611 4336 w (about) 1882 4336 w (C) 2130 4336 w (is) 2223 4336 w (that) 2316 4336 w (the) 2492 4336 w 10 /Helvetica f (statement) 2643 4336 w 10 /Times-Roman f (part) 3110 4336 w (of) 3291 4336 w (an) 3400 4336 w 10 /Helvetica f (if) 3523 4336 w 10 /Times-Roman f (can) 3599 4336 w (be) 3763 4336 w (made) 3883 4336 w (arbitrarily) 4126 4336 w (complicated) 4552 4336 w (by) 720 4456 w (enclosing) 854 4456 w (a) 1271 4456 w (set) 1349 4456 w (of) 1494 4456 w (statements) 1611 4456 w (in) 2067 4456 w ({}.) 2179 4456 w (As) 2358 4456 w (a) 2502 4456 w (simple) 2579 4456 w (example,) 2879 4456 w (suppose) 3275 4456 w (we) 3630 4456 w (want) 3779 4456 w (to) 4006 4456 w (ensure) 4117 4456 w (that) 4410 4456 w 10 /Helvetica f (a) 4596 4456 w 10 /Times-Roman f (is) 4685 4456 w (bigger) 4785 4456 w (than) 720 4576 w 10 /Helvetica f (b,) 924 4576 w 10 /Times-Roman f (as) 1037 4576 w (part) 1150 4576 w (of) 1335 4576 w (a) 1448 4576 w (sort) 1522 4576 w (routine.) 1702 4576 w (The) 2065 4576 w (interchange) 2250 4576 w (of) 2745 4576 w 10 /Helvetica f (a) 2861 4576 w 10 /Times-Roman f (and) 2947 4576 w 10 /Helvetica f (b) 3124 4576 w 10 /Times-Roman f (takes) 3210 4576 w (three) 3445 4576 w (statements) 3674 4576 w (in) 4126 4576 w (C,) 4234 4576 w (grouped) 4356 4576 w (together) 4713 4576 w (by {}:) 720 4696 w 10 /Helvetica f (if) 1080 4866 w (\(a) 1165 4866 w (<) 1289 4866 w (b\)) 1382 4866 w ({) 1506 4866 w (t) 1440 4986 w (=) 1503 4986 w (a;) 1596 4986 w (a) 1440 5106 w (=) 1531 5106 w (b;) 1624 5106 w (b) 1440 5226 w (=) 1531 5226 w (t;) 1624 5226 w (}) 1080 5346 w 10 /Times-Roman f (As) 970 5552 w (a) 1112 5552 w (general) 1187 5552 w (rule) 1511 5552 w (in) 1697 5552 w (C,) 1806 5552 w (anywhere) 1929 5552 w (you) 2347 5552 w (can) 2528 5552 w (use) 2697 5552 w (a) 2862 5552 w (simple) 2938 5552 w (statement,) 3237 5552 w (you) 3677 5552 w (can) 3859 5552 w (use) 4029 5552 w (any) 4194 5552 w (compound) 4370 5552 w (state\255) 4824 5552 w (ment,) 720 5672 w (which) 971 5672 w (is) 1241 5672 w (just) 1334 5672 w (a) 1505 5672 w (number) 1575 5672 w (of) 1906 5672 w (simple) 2015 5672 w (or) 2308 5672 w (compound) 2417 5672 w (ones) 2865 5672 w (enclosed) 3074 5672 w (in) 3449 5672 w ({}.) 3553 5672 w (There) 3725 5672 w (is) 3983 5672 w (no) 4076 5672 w (semicolon after the }) 4202 5672 w (of a compound statement, but there) 720 5792 w 10 /Times-Italic f (is) 2154 5792 w 10 /Times-Roman f (a semicolon after the last non\255compound statement inside the {}.) 2246 5792 w (The) 970 5948 w (ability) 1160 5948 w (to) 1451 5948 w (replace) 1564 5948 w (single) 1886 5948 w (statements) 2160 5948 w (by) 2617 5948 w (complex) 2752 5948 w (ones) 3131 5948 w (at) 3349 5948 w (will) 3456 5948 w (is) 3647 5948 w (one) 3749 5948 w (feature) 3928 5948 w (that) 4239 5948 w (makes) 4424 5948 w (C) 4715 5948 w (much) 4818 5948 w (more) 720 6068 w (pleasant) 954 6068 w (to) 1310 6068 w (use) 1417 6068 w (than) 1579 6068 w (Fortran.) 1780 6068 w (Logic) 2153 6068 w (\(like) 2415 6068 w (the) 2627 6068 w (exchange) 2777 6068 w (in) 3181 6068 w (the) 3287 6068 w (previous) 3437 6068 w (example\)) 3809 6068 w (which) 4208 6068 w (would) 4480 6068 w (require) 4758 6068 w (several) 720 6188 w (GOTO's) 1038 6188 w (and) 1424 6188 w (labels) 1605 6188 w (in) 1875 6188 w (Fortran) 1990 6188 w (can) 2321 6188 w (and) 2496 6188 w (should) 2677 6188 w (be) 2981 6188 w (done) 3112 6188 w (in) 3343 6188 w (C) 3458 6188 w (without) 3562 6188 w (any,) 3905 6188 w (using) 4111 6188 w (compound) 4365 6188 w (state\255) 4824 6188 w (ments.) 720 6308 w 10 /Helvetica f (7. While Statement; Assignment within an Expression; Null Statement) 720 6548 w 10 /Times-Roman f (The) 970 6704 w (basic) 1155 6704 w (looping) 1390 6704 w (mechanism) 1726 6704 w (in) 2211 6704 w (C) 2319 6704 w (is) 2416 6704 w (the) 2513 6704 w 10 /Helvetica f (while) 2669 6704 w 10 /Times-Roman f (statement.) 2928 6704 w (Here's) 3392 6704 w (a) 3688 6704 w (program) 3763 6704 w (that) 4132 6704 w (copies) 4313 6704 w (its) 4599 6704 w (input) 4725 6704 w (to) 4962 6704 w (its output a character at a time.) 720 6824 w (Remember that `\\0' marks the end of file.) 1998 6824 w 10 /Helvetica f (main\( ) 1080 6994 w (\)) 1365 6994 w ({) 1433 6994 w (char) 1440 7114 w (c;) 1670 7114 w (while\() 1440 7234 w (\(c=getchar\( ) 1736 7234 w (\)\)) 2280 7234 w (!=) 2381 7234 w 10 /S f (\242) 2502 7234 w 10 /Helvetica f (\\0) 2527 7234 w 10 /S f (\242) 2611 7234 w 10 /Helvetica f (\)) 2671 7234 w cleartomark showpage saveobj restore %%EndPage: 4 4 %%Page: 5 5 /saveobj save def mark 5 pagesetup 10 /Helvetica f (C ) 720 360 w (Tutorial) 827 360 w 10 /S f (-) 2942 360 w 10 /Helvetica f (5 ) 3032 360 w 10 /S f (-) 3123 360 w 10 /Helvetica f (putchar\(c\);) 1800 840 w (}) 1080 960 w 10 /Times-Roman f (The) 720 1130 w 10 /Helvetica f (while) 903 1130 w 10 /Times-Roman f (statement is a loop, whose general form is) 1156 1130 w 10 /Helvetica f (while) 1080 1300 w (\(expression\)) 1343 1300 w (statement) 1929 1300 w 10 /Times-Roman f (Its meaning is) 720 1470 w 10 /Helvetica f (\(a\)) 1080 1640 w (evaluate) 1237 1640 w (the) 1652 1640 w (expression) 1827 1640 w (\(b\)) 1080 1760 w (if) 1237 1760 w (its) 1322 1760 w (value) 1457 1760 w (is) 1732 1760 w (true) 1839 1760 w (\(i) 2047 1760 w 16 /Helvetica f (.) 2102 1760 w 10 /Helvetica f (e) 2147 1760 w 16 /Helvetica f (.) 2203 1760 w 10 /Helvetica f (,) 2248 1760 w (not) 2311 1760 w (zero\)) 2486 1760 w (do) 1800 1880 w (the) 1947 1880 w (statement,) 2122 1880 w (and) 2626 1880 w (go) 2829 1880 w (back) 2976 1880 w (to) 3223 1880 w (\(a\)) 3342 1880 w 10 /Times-Roman f (Because) 720 2050 w (the) 1084 2050 w (expression) 1238 2050 w (is) 1697 2050 w (tested) 1796 2050 w (before) 2061 2050 w (the) 2347 2000 2050 w (statement) 2501 2050 w (is) 2916 2050 w (executed,) 3015 2050 w (the) 3426 2050 w (statement) 3580 2050 w (part) 3996 2050 w (can) 4184 2050 w (be) 4355 2050 w (executed) 4482 2050 w (zero) 4869 2050 w (times,) 720 2170 w (which) 995 2170 w (is) 1272 2170 w (often) 1372 2170 w (desirable.) 1610 2170 w (As) 2053 2170 w (in) 2197 2170 w (the) 2308 2170 w 10 /Helvetica f (if) 2466 2170 w 10 /Times-Roman f (statement,) 2548 2170 w (the) 2988 2170 w (expression) 3142 2170 w (and) 3601 2170 w (the) 3777 2170 w (statement) 3931 2170 w (can) 4346 2170 w (both) 4516 2170 w (be) 4726 2170 w (arbi\255) 4852 2170 w (trarily) 720 2290 w (complicated,) 992 2290 w (although) 1533 2290 w (we) 1911 2290 w (haven't) 2055 2290 w (seen) 2382 2290 w (that) 2587 2290 w (yet.) 2765 2290 w (Our) 2966 2290 w (example) 3150 2290 w (gets) 3517 2290 w (the) 3707 2290 w (character,) 3858 2290 w (assigns) 4276 2290 w (it) 4594 2290 w (to) 4679 2290 w 10 /Helvetica f (c,) 4789 2290 w 10 /Times-Roman f (and) 4896 2290 w (then) 720 2410 w (tests) 920 2410 w (if) 1126 2410 w (it's) 1215 2410 w (a) 1371 2410 w (`\\0''.) 1443 2410 w (If) 1698 2410 w (it) 1792 2410 w (is) 1876 2410 w (not) 1971 2410 w (a) 2127 2410 w (`\\0',) 2199 2410 w (the) 2396 2410 w (statement) 2546 2410 w (part) 2957 2410 w (of) 3140 2410 w (the) 3251 2410 w 10 /Helvetica f (while) 3403 2410 w 10 /Times-Roman f (is) 3658 2410 w (executed,) 3752 2410 w (printing) 4158 2410 w (the) 4502 2410 w (character.) 4651 2410 w (The) 720 2530 w 10 /Helvetica f (while) 903 2530 w 10 /Times-Roman f (then repeats.) 1156 2530 w (When the input character is finally a `\\0', the) 1710 2530 w 10 /Helvetica f (while) 3531 2530 w 10 /Times-Roman f (terminates, and so does) 3784 2530 w 10 /Helvetica f (main) 4744 2530 w 16 /Helvetica f (.) 4961 2530 w 10 /Times-Roman f (Notice that we used an assignment statement) 970 2686 w 10 /Helvetica f (c) 1080 2856 w (=) 1165 2856 w (getchar\( ) 1258 2856 w (\)) 1661 2856 w 10 /Times-Roman f (within) 720 3026 w (an) 1007 3026 w (expression.) 1132 3026 w (This) 1640 3026 w (is) 1849 3026 w (a) 1947 3026 w (handy) 2022 3026 w (notational) 2297 3026 w (shortcut) 2728 3026 w (which) 3081 3026 w (often) 3356 3026 w (produces) 3592 3026 w (clearer) 3984 3026 w (code.) 4286 3026 w (\(In) 4556 3026 w (fact) 4704 3026 w (it) 4885 3026 w (is) 4973 3026 w (often) 720 3146 w (the) 951 3146 w (only) 1099 3146 w (way) 1303 3146 w (to) 1495 3146 w (write) 1599 3146 w (the) 1830 3146 w (code) 1978 3146 w (cleanly.) 2192 3146 w (As) 2556 3146 w (an) 2693 3146 w (exercise,) 2813 3146 w (re\255write) 3190 3146 w (the) 3531 3146 w (file\255copy) 3679 3146 w (without using an assign\255) 4065 3146 w (ment) 720 3266 w (inside) 946 3266 w (an) 1211 3266 w (expression.\)) 1331 3266 w (It) 1867 3266 w (works) 1954 3266 w (because) 2224 3266 w (an) 2565 3266 w (assignment) 2685 3266 w (statement) 3161 3266 w (has) 3570 3266 w (a) 3729 3266 w (value,) 3799 3266 w (just) 4066 3266 w (as) 4237 3266 w (any) 4346 3266 w (other) 4516 3266 w (expres\255) 4747 3266 w (sion) 720 3386 w (does.) 918 3386 w (Its) 1182 3386 w (value) 1313 3386 w (is) 1560 3386 w (the) 1658 3386 w (value) 1811 3386 w (of) 2058 3386 w (the) 2172 3386 w (right) 2325 3386 w (hand) 2545 3386 w (side.) 2770 3386 w (This) 3012 3386 w (also) 3220 3386 w (implies) 3411 3386 w (that) 3736 3386 w (we) 3916 3386 w (can) 4062 3386 w (use) 4230 3386 w (multiple) 4393 3386 w (assign\255) 4757 3386 w (ments like) 720 3506 w 10 /Helvetica f (x) 1080 3676 w (=) 1165 3676 w (y) 1258 3676 w (=) 1343 3676 w (z) 1436 3676 w (=) 1521 3676 w (0;) 1614 3676 w 10 /Times-Roman f (Evaluation goes from right to left.) 720 3846 w (By) 970 4002 w (the) 1113 4002 w (way,) 1261 4002 w (the) 1478 4002 w (extra) 1627 4002 w (parentheses) 1853 4002 w (in) 2345 4002 w (the) 2450 4002 w (assignment) 2599 4002 w (statement) 3076 4002 w (within) 3486 4002 w (the) 3769 4002 w (conditional) 3918 4002 w (were) 4395 4002 w (really) 4615 4002 w (nec\255) 4869 4002 w (essary: if we had said) 720 4122 w 10 /Helvetica f (c) 1080 4292 w (=) 1165 4292 w (getchar\( ) 1258 4292 w (\)) 1661 4292 w (!=) 1729 4292 w 10 /S f (\242) 1850 4292 w 10 /Helvetica f (\\0) 1875 4292 w 10 /S f (\242) 1959 4292 w 10 /Helvetica f (c) 720 4462 w 10 /Times-Roman f (would) 800 4462 w (be) 1080 4462 w (set) 1204 4462 w (to) 1345 4462 w (0) 1453 4462 w (or) 1533 4462 w (1) 1646 4462 w (depending) 1726 4462 w (on) 2172 4462 w (whether) 2302 4462 w (the) 2653 4462 w (character) 2805 4462 w (fetched) 3199 4462 w (was) 3522 4462 w (an) 3707 4462 w (end) 3831 4462 w (of) 4005 4462 w (file) 4119 4462 w (or) 4283 4462 w (not.) 4397 4462 w (This) 4606 4462 w (is) 4815 4462 w (be\255) 4913 4462 w (cause) 720 4582 w (in) 978 4582 w (the) 1093 4582 w (absence) 1252 4582 w (of) 1604 4582 w (parentheses) 1724 4582 w (the) 2226 4582 w (assignment) 2385 4582 w (operator) 2872 4582 w (`=') 3240 4582 w (is) 3398 4582 w (evaluated) 3501 4582 w (after) 3919 4582 w (the) 4137 4582 w (relational) 4295 4582 w (operator) 4708 4582 w (`!='.) 720 4702 w (When in doubt, or even if not, parenthesize.) 950 4702 w (Since) 970 4858 w 10 /Helvetica f (putchar\(c\)) 1225 4858 w 10 /Times-Roman f (returns) 1706 4858 w 10 /Helvetica f (c) 2016 4858 w 10 /Times-Roman f (as) 2096 4858 w (its) 2209 4858 w (function) 2334 4858 w (value,) 2697 4858 w (we) 2968 4858 w (could) 3114 4858 w (also) 3366 4858 w (copy) 3557 4858 w (the) 3781 4858 w (input) 3933 4858 w (to) 4169 4858 w (the) 4277 4858 w (output) 4429 4858 w (by) 4715 4858 w (nest\255) 4846 4858 w (ing the calls to) 720 4978 w 10 /Helvetica f (getchar) 1334 4978 w 10 /Times-Roman f (and) 1694 4978 w 10 /Helvetica f (putchar:) 1866 4978 w (main\( ) 1080 5148 w (\)) 1365 5148 w ({) 1433 5148 w (while\() 1440 5268 w (putchar\(getchar\( ) 1736 5268 w (\)\)) 2507 5268 w (!=) 2608 5268 w 10 /S f (\242) 2729 5268 w 10 /Helvetica f (\\0) 2754 5268 w 10 /S f (\242) 2838 5268 w 10 /Helvetica f (\)) 2898 5268 w (;) 2966 5268 w (}) 1080 5388 w 10 /Times-Roman f (What) 720 5558 w (statement) 968 5558 w (is) 1383 5558 w (being) 1482 5558 w (repeated? ) 1736 5558 w (None,) 2174 5558 w (or) 2447 5558 w (technically,) 2562 5558 w (the) 3057 5558 w 10 /Times-Italic f (null) 3211 5558 w 10 /Times-Roman f (statement,) 3399 5558 w (because) 3839 5558 w (all) 4187 5558 w (the) 4320 5558 w (work) 4475 5558 w (is) 4713 5558 w (really) 4813 5558 w (done) 720 5678 w (within) 942 5678 w (the) 1226 5678 w (test) 1376 5678 w (part) 1543 5678 w (of) 1726 5678 w (the) 1837 5678 w 10 /Helvetica f (while) 1990 5678 w 16 /Helvetica f (.) 2218 5678 w 10 /Times-Roman f (This) 2316 5678 w (version) 2522 5678 w (is) 2844 5678 w (slightly) 2939 5678 w (different) 3268 5678 w (from) 3639 5678 w (the) 3860 5678 w (previous) 4009 5678 w (one,) 4380 5678 w (because) 4576 5678 w (the) 4918 5678 w (final `\\0' is copied to the output before we decide to stop.) 720 5798 w 10 /Helvetica f (8. Arithmetic) 720 6038 w 10 /Times-Roman f (The) 970 6194 w (arithmetic) 1152 6194 w (operators) 1584 6194 w (are) 1982 6194 w (the) 2130 6194 w (usual) 2279 6194 w (`+',) 2517 6194 w (`) 2691 6194 w 10 /S f (-) 2724 6194 w 10 /Times-Roman f (',) 2779 6194 w (`*',) 2864 6194 w (and) 3032 6194 w (`/') 3203 6194 w (\(truncating) 3324 6194 w (integer) 3789 6194 w (division) 4093 6194 w (if) 4443 6194 w (the) 4531 6194 w (operands) 4680 6194 w (are both) 720 6314 w 10 /Helvetica f (int\),) 1072 6314 w 10 /Times-Roman f (and the remainder or mod operator `%':) 1264 6314 w 10 /Helvetica f (x) 1080 6484 w (=) 1165 6484 w (a%b;) 1258 6484 w 10 /Times-Roman f (sets) 720 6654 w 10 /Helvetica f (x) 899 6654 w 10 /Times-Roman f (to) 975 6654 w (the) 1079 6654 w (remainder) 1227 6654 w (after) 1657 6654 w 10 /Helvetica f (a) 1868 6654 w 10 /Times-Roman f (is) 1950 665 2000 4 w (divided) 2043 6654 w (by) 2369 6654 w 10 /Helvetica f (b) 2498 6654 w 10 /Times-Roman f (\(i.e.,) 2580 6654 w 10 /Helvetica f (a) 2789 6654 w (mod) 2874 6654 w (b\)) 3098 6654 w 16 /Helvetica f (.) 3187 6654 w 10 /Times-Roman f (The) 3284 6654 w (results) 3466 6654 w (are) 3754 6654 w (machine) 3902 6654 w (dependent) 4267 6654 w (unless) 4704 6654 w 10 /Helvetica f (a) 4984 6654 w 10 /Times-Roman f (and) 720 6774 w 10 /Helvetica f (b) 892 6774 w 10 /Times-Roman f (are both positive.) 973 6774 w (In) 970 6930 w (arithmetic,) 1091 6930 w 10 /Helvetica f (char) 1562 6930 w 10 /Times-Roman f (variables) 1795 6930 w (can) 2193 6930 w (usually) 2369 6930 w (be) 2696 6930 w (treated) 2828 6930 w (like) 3137 6930 w 10 /Helvetica f (int) 3328 6930 w 10 /Times-Roman f (variables.) 3472 6930 w (Arithmetic) 3920 6930 w (on) 4392 6930 w (characters) 4531 6930 w (is) 4973 6930 w (quite legal, and often makes sense:) 720 7050 w 10 /Helvetica f (c) 1080 7220 w (=) 1165 7220 w (c) 1258 7220 w (+) 1343 7220 w 10 /S f (\242) 1436 7220 w 10 /Helvetica f (A) 1461 7220 w 10 /S f (\242) 1528 7220 w (-) 1588 7220 w (\242) 1678 7220 w 10 /Helvetica f (a) 1703 7220 w 10 /S f (\242) 1759 7220 w 10 /Helvetica f (;) 1784 7220 w cleartomark showpage saveobj restore %%EndPage: 5 5 %%Page: 6 6 /saveobj save def mark 6 pagesetup 10 /Helvetica f (C ) 720 360 w (Tutorial) 827 360 w 10 /S f (-) 2942 360 w 10 /Helvetica f (6 ) 3032 360 w 10 /S f (-) 3123 360 w 10 /Times-Roman f (converts) 720 890 w (a) 1095 890 w (single) 1176 890 w (lower) 1452 890 w (case) 1716 890 w (ascii) 1924 890 w (character) 2144 890 w (stored) 2545 890 w (in) 2826 890 w 10 /Helvetica f (c) 2944 890 w 10 /Times-Roman f (to) 3031 890 w (upper) 3146 890 w (case,) 3410 890 w (making) 3643 890 w (use) 3980 890 w (of) 4150 890 w (the) 4270 890 w (fact) 4429 890 w (that) 4615 890 w (corre\255) 4803 890 w (sponding) 720 1010 w (ascii) 1113 1010 w (letters are a fixed distance apart.) 1322 1010 w (The rule governing this arithmetic is that all) 2662 1010 w 10 /Helvetica f (chars) 4447 1010 w 10 /Times-Roman f (are con\255) 4717 1010 w (verted) 720 1130 w (to) 995 1130 w 10 /Helvetica f (int) 1102 1130 w 10 /Times-Roman f (before) 1234 1130 w (the) 1514 1130 w (arithmetic) 1662 1130 w (is) 2093 1130 w (done.) 2186 1130 w (Beware) 2456 1130 w (that) 2786 1130 w (conversion) 2962 1130 w (may) 3426 1130 w (involve) 3624 1130 w (sign\255extension) 3950 1130 w 10 /S f (_) 4560 1130 w 10 /Times-Roman f (if) 4637 1130 w (the) 4725 1130 w (left\255) 4874 1130 w (most) 720 1250 w (bit) 953 1250 w (of) 1097 1250 w (a) 1218 1250 w (character) 1300 1250 w (is) 1702 1250 w (1,) 1806 1250 w (the) 1918 1250 w (resulting) 2077 1250 w (integer) 2464 1250 w (might) 2778 1250 w (be) 3049 1250 w (negative.) 3180 1250 w (\(This) 3605 1250 w (doesn't) 3853 1250 w (happen) 4184 1250 w (with) 4509 1250 w (genuine) 4724 1250 w (characters on any current machine.\)) 720 1370 w (So to convert a file into lower case:) 970 1526 w 10 /Helvetica f (main\() 1080 1696 w (\)) 1365 1696 w ({) 1433 1696 w (char) 1440 1816 w (c;) 1670 1816 w (while\() 1440 1936 w (\(c=getchar\() 1736 1936 w (\)\)) 2280 1936 w (!=) 2381 1936 w 10 /S f (\242) 2502 1936 w 10 /Helvetica f (\\0) 2527 1936 w 10 /S f (\242) 2611 1936 w 10 /Helvetica f (\)) 2671 1936 w (if\() 1800 2056 w 10 /S f (\242) 1918 2056 w 10 /Helvetica f (A) 1943 2056 w 10 /S f (\242) 2010 2056 w 10 /Helvetica f (<=c) 2035 2056 w (&&) 2236 2056 w (c<=) 2405 2056 w 10 /S f (\242) 2571 2056 w 10 /Helvetica f (Z) 2596 2056 w 10 /S f (\242) 2657 2056 w 10 /Helvetica f (\)) 2717 2056 w (putchar\(c+) 2160 2176 w 10 /S f (\242) 2636 2176 w 10 /Helvetica f (a) 2661 2176 w 10 /S f (\242-\242) 2717 2176 w 10 /Helvetica f (A) 2822 2176 w 10 /S f (\242) 2889 2176 w 10 /Helvetica f (\);) 2914 2176 w (else) 1800 2296 w (putchar\(c\);) 2160 2416 w (}) 1080 2536 w 10 /Times-Roman f (Characters) 720 2706 w (have) 1176 2706 w (different) 1394 2706 w (sizes) 1768 2706 w (on) 1993 2706 w (different) 2124 2706 w (machines.) 2498 2706 w (Further,) 2956 2706 w (this) 3306 2706 w (code) 3482 2706 w (won't) 3701 2706 w (work) 3965 2706 w (on) 4201 2706 w (an) 4332 2706 w (IBM) 4457 2706 w (machine,) 4677 2706 w (because the letters in the ebcdic alphabet are not contiguous.) 720 2826 w 10 /Helvetica f (9. Else Clause; Conditional Expressions) 720 3066 w 10 /Times-Roman f (We just used an) 970 3222 w 10 /Helvetica f (else) 1633 3222 w 10 /Times-Roman f (after an) 1842 3222 w 10 /Helvetica f (if) 2171 3222 w 16 /Helvetica f (.) 2221 3222 w 10 /Times-Roman f (The most general form of) 2316 3222 w 10 /Helvetica f (if) 3364 3222 w 10 /Times-Roman f (is) 3439 3222 w 10 /Helvetica f (if) 1080 3392 w (\(expression\)) 1165 3392 w (statement1) 1751 3392 w (else) 2283 3392 w (statement2) 2502 3392 w 10 /Times-Roman f (the) 720 3562 w 10 /Helvetica f (else) 870 3562 w 10 /Times-Roman f (part is optional, but often useful.) 1079 3562 w (The canonical example sets) 2431 3562 w 10 /Helvetica f (x) 3559 3562 w 10 /Times-Roman f (to the minimum of) 3634 3562 w 10 /Helvetica f (a) 4410 3562 w 10 /Times-Roman f (and) 4491 3562 w 10 /Helvetica f (b:) 4663 3562 w (if) 1080 3732 w (\(a) 1165 3732 w (<) 1289 3732 w (b\)) 1382 3732 w (x) 1440 3852 w (=) 1525 3852 w (a;) 1618 3852 w (else) 1080 3972 w (x) 1440 4092 w (=) 1525 4092 w (b;) 1618 4092 w 10 /Times-Roman f (Observe that there's a semicolon after) 720 4262 w 10 /Helvetica f (x=a) 2263 4262 w 16 /Helvetica f (.) 2427 4262 w 10 /Times-Roman f (C) 970 4418 w (provides) 1063 4418 w (an) 1433 4418 w (alternate) 1553 4418 w (form) 1922 4418 w (of) 2142 4418 w (conditional) 2251 4418 w (which) 2727 4418 w (is) 2997 4418 w (often) 3090 4418 w (more) 3321 4418 w (concise.) 3552 4418 w (It) 3928 4418 w (is) 4016 4418 w (called) 4110 4418 w (the) 4375 4418 w (``conditional) 4524 4418 w (expression'') 720 4538 w (because) 1241 4538 w (it) 1584 4538 w (is) 1668 4538 w (a) 1763 4538 w (conditional) 1835 4538 w (which) 2313 4538 w (actually) 2585 4538 w (has) 2929 4538 w (a) 3090 4538 w (value) 3162 4538 w (and) 3406 4538 w (can) 3578 4538 w (be) 3744 4538 w (used) 3866 4538 w (anywhere) 4077 4538 w (an) 4492 4538 w (expression) 4613 4538 w (can.) 720 4658 w (The value of) 933 4658 w 10 /Helvetica f (a127) 3046 1236 w (or) 3497 1236 w (<0\)) 3609 1236 w (into) 3777 1236 w (one) 3962 1236 w (pile.) 4134 1236 w (Since) 4362 1236 w (this) 4612 1236 w (is) 4785 1236 w (pre\255) 4880 1236 w (sumably) 720 1356 w (an) 1089 1356 w (isolated) 1213 1356 w (part) 1554 1356 w (of) 1739 1356 w (the) 1852 1356 w (program,) 2004 1356 w (good) 2397 1356 w (practice) 2628 1356 w (dictates) 2974 1356 w (making) 3310 1356 w (it) 3641 1356 w (a) 3728 1356 w (separate) 3803 1356 w (function.) 4160 1356 w (Here) 4574 1356 w (is) 4798 1356 w (one) 4896 1356 w (way:) 720 1476 w 10 /Helvetica f (main\( ) 1080 1646 w (\)) 1365 1646 w ({) 1433 1646 w (int) 1440 1766 w (hist[129];) 1581 1766 w (/) 2520 1766 w 14 /Helvetica f (*) 2548 1815 w 10 /Helvetica f (128) 2638 1766 w (legal) 2841 1766 w (chars) 3088 1766 w (+) 3368 1766 w (1) 3461 1766 w (illegal) 3552 1766 w (group) 3843 1766 w 14 /Helvetica f (*) 4135 1815 w 10 /Helvetica f (/) 4190 1766 w 16 /Helvetica f (...) 1440 1886 w 10 /Helvetica f (count\(hist,) 1440 2006 w (128\);) 1938 2006 w (/) 2520 2006 w 14 /Helvetica f (*) 2548 2055 w 10 /Helvetica f (count) 2638 2006 w (the) 2919 2006 w (letters) 3094 2006 w (into) 3402 2006 w (hist) 3599 2006 w 14 /Helvetica f (*) 3790 2055 w 10 /Helvetica f (/) 3845 2006 w (printf\() 1440 2126 w 16 /Helvetica f (...) 1731 2126 w 10 /Helvetica f (\);) 1901 2126 w (/) 2520 2126 w 14 /Helvetica f (*) 2548 2175 w 10 /Helvetica f (comments) 2638 2126 w (look) 3135 2126 w (like) 3354 2126 w (this;) 3539 2126 w (use) 3758 2126 w (them) 3955 2126 w 14 /Helvetica f (*) 4213 2175 w 10 /Helvetica f (/) 4268 2126 w 16 /Helvetica f (...) 1440 2246 w 10 /Helvetica f (/) 2160 2246 w 14 /Helvetica f (*) 2188 2295 w 10 /Helvetica f (anywhere) 2278 2246 w (blanks,) 2748 2246 w (tabs) 3101 2246 w (or) 3326 2246 w (newlines) 3450 2246 w (could) 3875 2246 w (appear) 4150 2246 w 14 /Helvetica f (*) 4498 2295 w 10 /Helvetica f (/) 4553 2246 w (}) 1080 2366 w (count\(buf,) 1080 2536 w (size\)) 1562 2536 w (int) 1185 2656 w (size,) 1326 2656 w (buf[) 1567 2656 w (];) 1770 2656 w ({) 1861 2656 w (int) 1440 2776 w (i,) 1581 2776 w (c;) 1666 2776 w (for\() 1440 2896 w (i=0;) 1625 2896 w (i<=size;) 1824 2896 w (i) 2203 2896 w 10 /Times-Roman f (++) 2225 2896 w 10 /Helvetica f (\)) 2372 2896 w (buf[i]) 1800 3016 w (=) 2053 3016 w (0;) 2146 3016 w (/) 3240 3016 w 14 /Helvetica f (*) 3268 3065 w 10 /Helvetica f (set) 3358 3016 w (buf) 3527 3016 w (to) 3702 3016 w (zero) 3821 3016 w 14 /Helvetica f (*) 4051 3065 w 10 /Helvetica f (/) 4106 3016 w (while\() 1440 3136 w (\(c=getchar\( ) 1736 3136 w (\)\)) 2280 3136 w (!=) 2381 3136 w 10 /S f (\242) 2502 3136 w 10 /Helvetica f (\\0) 2527 3136 w 10 /S f (\242) 2611 3136 w 10 /Helvetica f (\)) 2671 3136 w ({) 2739 3136 w (/) 2880 3136 w 14 /Helvetica f (*) 2908 3185 w 10 /Helvetica f (read) 2998 3136 w (til) 3234 3136 w (eof) 3341 3136 w 14 /Helvetica f (*) 3516 3185 w 10 /Helvetica f (/) 3571 3136 w (if\() 1800 3256 w (c) 1918 3256 w (>) 2003 3256 w (size) 2096 3256 w 10 /S f (|) 2309 3256 w (|) 2345 3256 w 10 /Helvetica f (c) 2400 3256 w (<) 2485 3256 w (0) 2578 3256 w (\)) 2669 3256 w (c) 2160 3376 w (=) 2245 3376 w (size;) 2338 3376 w (/) 3240 3376 w 14 /Helvetica f (*) 3268 3425 w 10 /Helvetica f (fix) 3358 3376 w (illegal) 3493 3376 w (input) 3784 3376 w 14 /Helvetica f (*) 4037 3425 w 10 /Helvetica f (/) 4092 3376 w (buf[c]) 1800 3496 w 10 /Times-Roman f (++) 2046 3496 w 10 /Helvetica f (;) 2158 3496 w (}) 1440 3616 w (return;) 1440 3736 w (}) 1080 3856 w 10 /Times-Roman f (We) 720 4026 w (have) 895 4026 w (already) 1120 4026 w (seen) 1450 4026 w (many) 1664 4026 w (examples) 1923 4026 w (of) 2337 4026 w (calling) 2457 4026 w (a) 2766 4026 w (function,) 2847 4026 w (so) 3242 4026 w (let) 3368 4026 w (us) 3505 4026 w (concentrate) 3631 4026 w (on) 4127 4026 w (how) 4264 4026 w (to) 4473 4026 w 10 /Times-Italic f (define) 4589 4026 w 10 /Times-Roman f (one.) 4871 4026 w (Since) 720 4146 w 10 /Helvetica f (count) 976 4146 w 10 /Times-Roman f (has) 1253 4146 w (two) 1417 4146 w (arguments,) 1598 4146 w (we) 2070 4146 w (need) 2217 4146 w (to) 2436 4146 w (declare) 2545 4146 w (them,) 2863 4146 w (as) 3119 4146 w (shown,) 3233 4146 w (giving) 3550 4146 w (their) 3837 4146 w (types,) 4051 4146 w (and) 4318 4146 w (in) 4493 4146 w (the) 4602 4146 w (case) 4755 4146 w (of) 4957 4146 w 10 /Helvetica f (buf,) 720 4266 w 10 /Times-Roman f (the fact that it is an array.) 913 4266 w (The) 1981 4266 2000 w (declarations) 2162 4266 w (of) 2670 4266 w (arguments) 2779 4266 w (go) 3221 4266 w 10 /Times-Italic f (between) 3347 4266 w 10 /Times-Roman f (the) 3700 4266 w (argument) 3848 4266 w (list) 4251 4266 w (and) 4400 4266 w (the) 4570 4266 w (opening) 4718 4266 w (`{'.) 720 4386 w (There is no need to specify the size of the array) 909 4386 w 10 /Helvetica f (buf,) 2826 4386 w 10 /Times-Roman f (for it is defined outside of) 3019 4386 w 10 /Helvetica f (count) 4082 4386 w 16 /Helvetica f (.) 4328 4386 w 10 /Times-Roman f (The) 970 4542 w 10 /Helvetica f (return) 1154 4542 w 10 /Times-Roman f (statement) 1442 4542 w (simply) 1851 4542 w (says) 2150 4542 w (to) 2348 4542 w (go) 2453 4542 w (back) 2580 4542 w (to) 2795 4542 w (the) 2900 4542 w (calling) 3049 4542 w (routine.) 3348 4542 w (In) 3708 4542 w (fact,) 3818 4542 w (we) 4019 4542 w (could) 4162 4542 w (have) 4411 4542 w (omitted) 4626 4542 w (it,) 4959 4542 w (since a return is implied at the end of a function.) 720 4662 w (What) 970 4818 w (if) 1212 4818 w (we) 1299 4818 w (wanted) 1441 4818 w 10 /Helvetica f (count) 1758 4818 w 10 /Times-Roman f (to) 2030 4818 w (return) 2134 4818 w (a) 2398 4818 w (value,) 2468 4818 w (say) 2735 4818 w (the) 2895 4818 w (number) 3044 4818 w (of) 3376 4818 w (characters) 3486 4818 w (read? ) 3916 4818 w (The) 4183 4818 w 10 /Helvetica f (return) 4368 4818 w 10 /Times-Roman f (statement) 4657 4818 w (allows for this too:) 720 4938 w 10 /Helvetica f (int) 1440 5108 w (i,) 1581 5108 w (c,) 1666 5108 w (nchar;) 1779 5108 w (nchar) 1440 5228 w (=) 1726 5228 w (0;) 1819 5228 w 16 /Helvetica f (...) 1440 5348 w 10 /Helvetica f (while\() 1440 5468 w (\(c=getchar\( ) 1736 5468 w (\)\)) 2280 5468 w (!=) 2381 5468 w 10 /S f (\242) 2502 5468 w 10 /Helvetica f (\\0) 2527 5468 w 10 /S f (\242) 2611 5468 w 10 /Helvetica f (\)) 2671 5468 w ({) 2739 5468 w (if\() 1800 5588 w (c) 1918 5588 w (>) 2003 5588 w (size) 2096 5588 w 10 /S f (|) 2309 5588 w (|) 2345 5588 w 10 /Helvetica f (c) 2400 5588 w (<) 2485 5588 w (0) 2578 5588 w (\)) 2669 5588 w (c) 2160 5708 w (=) 2245 5708 w (size;) 2338 5708 w (buf[c]) 1800 5828 w 10 /Times-Roman f (++) 2046 5828 w 10 /Helvetica f (;) 2158 5828 w (nchar) 1800 5948 w 10 /Times-Roman f (++) 2051 5948 w 10 /Helvetica f (;) 2163 5948 w (}) 1440 6068 w (return\(nchar\);) 1440 6188 w 10 /Times-Roman f (Any expression can appear within) 720 6358 w (the) 2104 6358 w (parentheses.) 2252 6358 w (Here) 2793 6358 w (is) 3012 6358 w (a) 3105 6358 w (function) 3175 6358 w (to) 3534 6358 w (compute) 3638 6358 w (the) 4008 6358 w (minimum) 4156 6358 w (of) 4572 6358 w (two) 4681 6358 w (inte\255) 4857 6358 w (gers:) 720 6478 w 10 /Helvetica f (min\(a,) 1080 6648 w (b\)) 1393 6648 w (int) 1185 6768 w (a,) 1326 6768 w (b;) 1445 6768 w ({) 1564 6768 w (return\() 1440 6888 w (a) 1770 6888 w (<) 1861 6888 w (b) 1954 6888 w (?) 2045 6888 w (a) 2136 6888 w (:) 2227 6888 w (b) 2290 6888 w (\);) 2381 6888 w (}) 1080 7008 w cleartomark showpage saveobj restore %%EndPage: 10 10 %%Page: 11 11 /saveobj save def mark 11 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 11 \255) 2952 360 w (To copy a character array, we could write the function) 970 912 w 10 /Helvetica f (strcopy\(s1,) 1080 1082 w (s2\)) 1605 1082 w (/) 2160 1082 w 14 /Helvetica f (*) 2188 1131 w 10 /Helvetica f (copies) 2278 1082 w (s1) 2603 1082 w (to) 2744 1082 w (s2) 2863 1082 w 14 /Helvetica f (*) 3004 1131 w 10 /Helvetica f (/) 3059 1082 w (char) 1185 1202 w (s1[) 1415 1202 w (],) 1584 1202 w (s2[) 1675 1202 w (];) 1844 1202 w ({) 1935 1202 w (int) 1440 1322 w (i;) 1581 1322 w (for\() 1440 1442 w (i) 1625 1442 w (=) 1682 1442 w (0;) 1775 1442 w (\(s2[i]) 1894 1442 w (=) 2146 1442 w (s1[i]\)) 2239 1442 w (!=) 2491 1442 w 10 /S f (\242) 2612 1442 w 10 /Helvetica f (\\0) 2637 1442 w 10 /S f (\242) 2721 1442 w 10 /Helvetica f (;) 2746 1442 w (i) 2809 1442 w 10 /Times-Roman f (++) 2831 1442 w 10 /Helvetica f (\);) 2978 1442 w (}) 1080 1562 w 10 /Times-Roman f (As) 720 1732 w (is) 859 1732 w (often) 954 1732 w (the) 1187 1732 w (case,) 1337 1732 w (all) 1561 1732 w (the) 1689 1732 w (work) 1839 1732 w (is) 2073 1732 w (done) 2169 1732 w (by) 2392 1732 w (the) 2521 1732 w (assignment) 2672 1732 w (statement) 3151 1732 w (embedded) 3563 1732 w (in) 4002 1732 w (the) 4109 1732 w (test) 4260 1732 w (part) 4428 1732 w (of) 4612 1732 w (the) 4724 1732 w 10 /Helvetica f (for) 4878 1732 w 16 /Helvetica f (.) 4995 1732 w 10 /Times-Roman f (Again,) 720 1852 w (the) 1021 1852 w (declarations) 1175 1852 w (of) 1689 1852 w (the) 1804 1852 w (arguments) 1958 1852 w 10 /Helvetica f (s1) 2409 1852 w 10 /Times-Roman f (and) 2547 1852 w 10 /Helvetica f (s2) 2726 1852 w 10 /Times-Roman f (omit) 2864 1852 w (the) 3080 1852 w (sizes,) 3233 1852 w (because) 3483 1852 w (they) 3829 1852 w (don't) 4032 1852 w (matter) 4274 1852 w (to) 4560 1852 w 10 /Helvetica f (strcopy) 4672 1852 w 16 /Helvetica f (.) 4995 1852 w 10 /Times-Roman f (\(In the section on pointers, we will see a more efficient way to do a string copy.\)) 720 1972 w (There) 970 2128 w (is) 1235 2128 w (a) 1335 2128 w (subtlety) 1412 2128 w (in) 1762 2128 w (function) 1873 2128 w (usage) 2239 2128 w (which) 2500 2128 w (can) 2778 2128 w (trap) 2950 2128 w (the) 3139 2128 w (unsuspecting) 3295 2128 w (Fortran) 3851 2128 w (programmer.) 4179 2128 w (Simple) 4756 2128 w (variables) 720 2248 w (\(not) 1112 2248 w (arrays\)) 1305 2248 w (are) 1613 2248 w (passed) 1766 2248 w (in) 2064 2248 w (C) 2174 2248 w (by) 2273 2248 w (``call) 2405 2248 w (by) 2647 2248 w (value'',) 2779 2248 w (which) 3117 2248 w (means) 3392 2248 w (that) 3678 2248 w (the) 3859 2248 w (called) 4012 2248 w (function) 4281 2248 w (is) 4645 2248 w (given) 4743 2248 w (a) 4996 2248 w (copy) 720 2368 w (of) 945 2368 w (its) 1059 2368 w (arguments,) 1185 2368 w (and) 1657 2368 w (doesn't) 1832 2368 w (know) 2157 2368 w (their) 2410 2368 w (addresses.) 2624 2368 w (This) 3087 2368 w (makes) 3296 2368 w (it) 3582 2368 w (impossible) 3669 2368 w (to) 4134 2368 w (change) 4243 2368 w (the) 4556 2368 w (value) 4709 2368 w (of) 4957 2368 w (one of the actual input arguments.) 720 2488 w (There) 970 2644 w (are) 1228 2644 w (two) 1375 2644 w (ways) 1551 2644 w (out) 1782 2644 w (of) 1937 2644 w (this) 2047 2644 w (dilemma.) 2219 2644 w (One) 2646 2644 w (is) 2839 2644 w (to) 2933 2644 w (make) 3038 2644 w (special) 3281 2644 w (arrangements) 3585 2644 w (to) 4149 2644 w (pass) 4254 2644 w (to) 4453 2644 w (the) 4558 2644 w (function) 4707 2644 w (the) 720 2764 w (address) 868 2764 w (of) 1193 2764 w (a) 1302 2764 w (variable) 1372 2764 w (instead) 1719 2764 w (of) 2028 2764 w (its) 2137 2764 w (value.) 2258 2764 w (The) 2550 2764 w (other) 2731 2764 w (is) 2962 2764 w (to) 3055 2764 w (make) 3159 2764 w (the) 3401 2764 w (variable) 3549 2764 w (a global or external variable,) 3896 2764 w (which is known to each function by its name.) 720 2884 w (We will discuss both possibilities in the next few sections.) 2582 2884 w 10 /Helvetica f (15. Local and External Variables) 720 3124 w 10 /Times-Roman f (If we say) 970 3280 w 10 /Helvetica f (f\() 1080 3450 w (\)) 1176 3450 w ({) 1244 3450 w (int) 1440 3570 w (x;) 1581 3570 w 16 /Helvetica f (...) 1440 3690 w 10 /Helvetica f (}) 1080 3810 w (g\() 1080 3930 w (\)) 1204 3930 w ({) 1272 3930 w (int) 1440 4050 w (x;) 1581 4050 w 16 /Helvetica f (...) 1440 4170 w 10 /Helvetica f (}) 1080 4290 w 10 /Times-Roman f (each) 720 4460 w 10 /Helvetica f (x) 930 4460 w 10 /Times-Roman f (is) 1005 4460 w 10 /Times-Italic f (local) 1097 4460 w 10 /Times-Roman f (to its own routine ) 1322 4460 w 10 /S f (_) 2050 4460 w 10 /Times-Roman f (the) 2125 4460 w 10 /Helvetica f (x) 2275 4460 w 10 /Times-Roman f (in) 2350 4460 w 10 /Helvetica f (f) 2456 4460 w 10 /Times-Roman f 2000 (is unrelated to the) 2509 4460 w 10 /Helvetica f (x) 3250 4460 w 10 /Times-Roman f (in) 3325 4460 w 10 /Helvetica f (g) 3431 4460 w 16 /Helvetica f (.) 3487 4460 w 10 /Times-Roman f (\(Local variables are also called ``au\255) 3582 4460 w (tomatic''.\)) 720 4580 w (Furthermore) 1200 4580 w (each) 1730 4580 w (local) 1943 4580 w (variable) 2168 4580 w (in) 2520 4580 w (a) 2629 4580 w (routine) 2704 4580 w (appears) 3018 4580 w (only) 3353 4580 w (when) 3562 4580 w (the) 3809 4580 w (function) 3962 4580 w (is) 4326 4580 w (called,) 4423 4580 w (and) 4716 4580 w 10 /Times-Italic f (dis\255) 4890 4580 w (appears) 720 4700 w 10 /Times-Roman f (when) 1073 4700 w (the) 1320 4700 w (function) 1473 4700 w (is) 1837 4700 w (exited.) 1935 4700 w (Local) 2260 4700 w (variables) 2518 4700 w (have) 2909 4700 w (no) 3128 4700 w (memory) 3259 4700 w (from) 3623 4700 w (one) 3849 4700 w (call) 4025 4700 w (to) 4201 4700 w (the) 4311 4700 w (next) 4465 4700 w (and) 4669 4700 w (must) 4845 4700 w (be) 720 4820 w (explicitly) 850 4820 w (initialized) 1264 4820 w (upon) 1700 4820 w (each) 1936 4820 w (entry.) 2154 4820 w (\(There) 2445 4820 w (is) 2746 4820 w (a) 2849 4820 w 10 /Helvetica f (static) 2931 4820 w 10 /Times-Roman f (storage) 3200 4820 w (class) 3523 4820 w (for) 3752 4820 w (making) 3903 4820 w (local) 4238 4820 w (variables) 4467 4820 w (with) 4862 4820 w (memory; we won't discuss it.\)) 720 4940 w (As) 970 5096 w (opposed) 1107 5096 w (to) 1466 5096 w (local) 1570 5096 w (variables,) 1790 5096 w 10 /Times-Italic f (external) 2202 5096 w (variables) 2556 5096 w 10 /Times-Roman f (are) 2955 5096 w (defined) 3103 5096 w (external) 3429 5096 w (to) 3777 5096 w (all) 3882 5096 w (functions,) 4009 5096 w (and) 4433 5096 w (are) 4604 5096 w (\(poten\255) 4752 5096 w (tially\)) 720 5216 w (available) 988 5216 w (to) 1377 5216 w (all) 1484 5216 w (functions.) 1612 5216 w (External) 2062 5216 w (storage) 2428 5216 w (always) 2744 5216 w (remains) 3049 5216 w (in) 3393 5216 w (existence.) 3499 5216 w (To) 3948 5216 w (make) 4087 5216 w (variables) 4331 5216 w (external) 4719 5216 w (we have to) 720 5336 w 10 /Times-Italic f (define) 1177 5336 w 10 /Times-Roman f (them external to all functions, and, wherever we want to use them, make a) 1446 5336 w 10 /Times-Italic f (declaration.) 4437 5336 w 10 /Helvetica f (main\( ) 1080 5506 w (\)) 1365 5506 w ({) 1433 5506 w (extern) 1440 5626 w (int) 1754 5626 w (nchar,) 1895 5626 w (hist[) 2209 5626 w (];) 2428 5626 w 16 /Helvetica f (...) 1440 5746 w 10 /Helvetica f (count\( ) 1440 5866 w (\);) 1754 5866 w 16 /Helvetica f (...) 1440 5986 w 10 /Helvetica f (}) 1080 6106 w (count\( ) 1080 6276 w (\)) 1394 6276 w ({) 1462 6276 w (extern) 1440 6396 w (int) 1754 6396 w (nchar,) 1895 6396 w (hist[) 2209 6396 w (];) 2428 6396 w (int) 1440 6516 w (i,) 1581 6516 w (c;) 1666 6516 w 16 /Helvetica f (...) 1440 6636 w 10 /Helvetica f (}) 1080 6756 w (int) 1080 6926 w (hist[129];) 1440 6926 w (/) 2160 6926 w 14 /Helvetica f (*) 2188 6975 w 10 /Helvetica f (space) 2278 6926 w (for) 2581 6926 w (histogram) 2733 6926 w 14 /Helvetica f (*) 3208 6975 w 10 /Helvetica f (/) 3263 6926 w (int) 1080 7046 w (nchar;) 1440 7046 w (/) 2160 7046 w 14 /Helvetica f (*) 2188 7095 w 10 /Helvetica f (character) 2278 7046 w (count) 2731 7046 w 14 /Helvetica f (*) 3012 7095 w 10 /Helvetica f (/) 3067 7046 w 10 /Times-Roman f (Roughly) 720 7216 w (speaking,) 1094 7216 w (any) 1503 7216 w (function) 1676 7216 w (that) 2038 7216 w (wishes) 2217 7216 w (to) 2518 7216 w (access) 2625 7216 w (an) 2909 7216 w (external) 3033 7216 w (variable) 3384 7216 w (must) 3735 7216 w (contain) 3960 7216 w (an) 4284 7216 w 10 /Helvetica f (extern) 4411 7216 w 10 /Times-Roman f (declara\255) 4720 7216 w cleartomark showpage saveobj restore %%EndPage: 11 11 %%Page: 12 12 /saveobj save def mark 12 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 12 \255) 2952 360 w (tion) 720 840 w (for) 902 840 w (it.) 1044 840 w (The) 1176 840 w (declaration) 1357 840 w (is) 1826 840 w (the) 1919 840 w (same) 2067 840 w (as) 2298 840 w (others,) 2407 840 w (except) 2702 840 w (for) 2988 840 w (the) 3130 840 w (added keyword) 3278 840 w 10 /Helvetica f (extern) 3918 840 w 16 /Helvetica f (.) 4197 840 w 10 /Times-Roman f (Furthermore, there) 4292 840 w (must somewhere be a) 720 960 w 10 /Times-Italic f (definition) 1607 960 w 10 /Times-Roman f (of the external variables external to all functions.) 2016 960 w (External) 970 1116 w (variables) 1341 1116 w (can) 1734 1116 w (be) 1905 1116 w (initialized;) 2032 1116 w (they) 2493 1116 w (are) 2698 1116 w (set) 2852 1116 w (to) 2996 1116 w (zero) 3107 1116 w (if) 3311 1116 w (not) 3405 1116 w (explicitly) 3566 1116 w (initialized.) 3977 1116 w (In) 4460 1116 w (its) 4577 1116 w (simplest) 4706 1116 w (form, initialization is done by putting the value \(which must be a constant\) after the definition:) 720 1236 w 10 /Helvetica f (int) 1080 1406 w (nchar) 1440 1406 w (0;) 1800 1406 w (char) 1080 1526 w (flag) 1440 1526 w 10 /S f (\242) 1800 1526 w 10 /Helvetica f (f) 1825 1526 w 10 /S f (\242) 1853 1526 w 10 /Helvetica f (;) 1878 1526 w 10 /Times-Roman f (etc) 1142 1646 w 16 /Times-Roman f (.) 1258 1646 w 10 /Times-Roman f (This is discussed further in a later section.) 720 1816 w (This) 970 2022 w (ends) 1184 2022 w (our) 1403 2022 w (discussion) 1572 2022 w (of) 2025 2022 w (what) 2144 2022 w (might) 2374 2022 w (be) 2644 2022 w (called) 2774 2022 w (the) 3048 2022 w (central) 3206 2022 w (core) 3513 2022 w (of) 3720 2022 w (C.) 3839 2022 w (You) 3992 2022 w (now) 4200 2022 w (have) 4408 2022 w (enough) 4632 2022 w (to) 4962 2022 w (write) 720 2142 w (quite) 956 2142 w (substantial) 1186 2142 w (C) 1644 2142 w (programs,) 1741 2142 w (and) 2173 2142 w (it) 2347 2142 w (would) 2433 2142 w (probably) 2713 2142 w (be) 3098 2142 w (a) 3222 2142 w (good) 3296 2142 w (idea) 3526 2142 w (if) 3722 2142 w (you) 3813 2142 w (paused) 3993 2142 w (long) 4300 2142 w (enough) 4508 2142 w (to) 4832 2142 w (do) 4940 2142 w (so.) 720 2262 w (The rest of this tutorial will describe some more ornate constructions, useful but not essential.) 884 2262 w 10 /Helvetica f (16. Pointers) 720 2602 w 10 /Times-Roman f (A) 970 2758 w 10 /Times-Italic f (pointer) 1074 2758 w 10 /Times-Roman f (in) 1395 2758 w (C) 1505 2758 w (is) 1604 2758 w (the) 1703 2758 w (address) 1857 2758 w (of) 2188 2758 w (something.) 2303 2758 w (It) 2802 2758 w (is) 2895 2758 w (a) 2994 2758 w (rare) 3070 2758 w (case) 3256 2758 w (indeed) 3459 2758 w (when) 3757 2758 w (we) 4005 2758 w (care) 4153 2758 w (what) 4350 2758 w (the) 4576 2758 w (specific) 4730 2758 w (address) 720 2878 w (itself) 1045 2878 w (is,) 1271 2878 w (but) 1389 2878 w (pointers) 1543 2878 w (are) 1891 2878 w (a) 2038 2878 w (quite) 2108 2878 w (common) 2334 2878 w (way) 2710 2878 w (to get at the contents of something.) 2902 2878 w (The unary opera\255) 4354 2878 w (tor `&' is used to produce the address of an object, if it has one. Thus) 720 2998 w 10 /Helvetica f (int) 1440 3168 w (a,) 1581 3168 w (b;) 1700 3168 w (b) 1440 3288 w (=) 1531 3288 w (&a;) 1624 3288 w 10 /Times-Roman f (puts) 720 3458 w (the) 916 3458 w (address) 1067 3458 w (of) 1395 3458 w 10 /Helvetica f (a) 1510 3458 w 10 /Times-Roman f (into) 1595 3458 w 10 /Helvetica f (b) 1783 3458 w 16 /Helvetica f (.) 1839 3458 w 10 /Times-Roman f (We) 1938 3458 w (can't) 2105 3458 w (do) 2333 3458 w (much) 2462 3458 w (with) 2713 3458 w (it) 2920 3458 w (except) 3005 3458 w (print) 3294 3458 w (it) 3512 3458 w (or) 3597 3458 w (pass) 3709 3458 w (it) 3910 3458 w (to) 3995 3458 w (some) 4102 3458 w (other) 4342 3458 w (routine,) 4576 3458 w (be\255) 4913 3458 w (cause) 720 3578 w (we) 967 3578 w (haven't) 1109 3578 w (given) 1434 3578 w 10 /Helvetica f (b) 1685 3578 w 10 /Tim 2000 es-Roman f (the) 1767 3578 w (right) 1915 3578 w (kind) 2130 3578 w (of) 2334 3578 w (declaration.) 2443 3578 w (But) 2962 3578 w (if) 3133 3578 w (we) 3220 3578 w (declare) 3362 3578 w (that) 3675 3578 w 10 /Helvetica f (b) 3854 3578 w 10 /Times-Roman f (is) 3936 3578 w (indeed) 4029 3578 w (a) 4321 3578 w 10 /Times-Italic f (pointer) 4391 3578 w 10 /Times-Roman f (to) 4706 3578 w (an in\255) 4810 3578 w (teger, we're in good shape:) 720 3698 w 10 /Helvetica f (int) 1440 3868 w (a,) 1581 3868 w 14 /Helvetica f (*) 1700 3917 w 10 /Helvetica f (b,) 1755 3868 w (c;) 1874 3868 w (b) 1440 3988 w (=) 1531 3988 w (&a;) 1624 3988 w (c) 1440 4108 w (=) 1525 4108 w 14 /Helvetica f (*) 1618 4157 w 10 /Helvetica f (b;) 1673 4108 w (b) 720 4278 w 10 /Times-Roman f (contains the address of) 801 4278 w 10 /Helvetica f (a) 1741 4278 w 10 /Times-Roman f (and) 1822 4278 w 10 /Helvetica f (`c =) 1994 4278 w 14 /Helvetica f (*) 2191 4327 w 10 /Helvetica f (b') 2246 4278 w 10 /Times-Roman f (means to use the value in) 2349 4278 w 10 /Helvetica f (b) 3384 4278 w 10 /Times-Roman f (as an address, i.e., as a pointer.) 3465 4278 w (The) 4749 4278 w (ef\255) 4930 4278 w (fect) 720 4398 w (is) 906 4398 w (that) 1010 4398 w (we) 1196 4398 w (get) 1348 4398 w (back) 1506 4398 w (the) 1730 4398 w (contents) 1888 4398 w (of) 2257 4398 w 10 /Helvetica f (a,) 2379 4398 w 10 /Times-Roman f (albeit) 2499 4398 w (rather) 2757 4398 w (indirectly.) 3025 4398 w (\(It's) 3494 4398 w (always) 3696 4398 w (the) 4009 4398 w (case) 4167 4398 w (that) 4374 4398 w 10 /Helvetica f (`) 4563 4398 w 14 /Helvetica f (*) 4585 4447 w 10 /Helvetica f (&x') 4640 4398 w 10 /Times-Roman f (is) 4815 4398 w (the) 4918 4398 w (same as) 720 4518 w 10 /Helvetica f (x) 1061 4518 w 10 /Times-Roman f (if) 1136 4518 w 10 /Helvetica f (x) 1225 4518 w 10 /Times-Roman f (has an address.\)) 1300 4518 w (The) 970 4674 w (most) 1155 4674 w (frequent) 1381 4674 w (use) 1744 4674 w (of) 1908 4674 w (pointers) 2022 4674 w (in) 2375 4674 w (C) 2484 4674 w (is) 2582 4674 w (for) 2680 4674 w (walking) 2827 4674 w (efficiently) 3180 4674 w (along) 3621 4674 w (arrays.) 3874 4674 w (In) 4198 4674 w (fact,) 4312 4674 w (in) 4517 4674 w (the) 4626 4674 w (imple\255) 4779 4674 w (mentation) 720 4794 w (of) 1147 4794 w (an) 1257 4794 w (array,) 1378 4794 w (the) 1634 4794 w (array) 1783 4794 w (name) 2014 4794 w (represents) 2257 4794 w (the) 2688 4794 w (address) 2837 4794 w (of) 3163 4794 w (the) 3273 4794 w (zeroth) 3421 4794 w (element) 3696 4794 w (of) 4038 4794 w (the) 4147 4794 w (array,) 4295 4794 w (so) 4550 4794 w (you) 4665 4794 w (can't) 4841 4794 w (use) 720 4914 w (it) 882 4914 w (on) 967 4914 w (the) 1096 4914 w (left) 1247 4914 w (side) 1409 4914 w (of) 1599 4914 w (an) 1711 4914 w (expression.) 1835 4914 w (\(You) 2342 4914 w (can't) 2577 4914 w (change) 2806 4914 w (the) 3118 4914 w (address) 3270 4914 w (of) 3599 4914 w (something) 3712 4914 w (by) 4159 4914 w (assigning) 4289 4914 w (to) 4697 4914 w (it.\)) 4805 4914 w (If) 4974 4914 w (we say) 720 5034 w 10 /Helvetica f (char) 1080 5204 w 14 /Helvetica f (*) 1310 5253 w 10 /Helvetica f (y;) 1365 5204 w (char) 1080 5324 w (x[100];) 1310 5324 w (y) 720 5494 w 10 /Times-Roman f (is) 801 5494 w (of) 899 5494 w (type) 1013 5494 w (pointer) 1216 5494 w (to) 1530 5494 w (character) 1639 5494 w (\(although) 2034 5494 w (it) 2448 5494 w (doesn't) 2535 5494 w (yet) 2860 5494 w (point) 3013 5494 w (anywhere\).) 3250 5494 w (We) 3751 5494 w (can) 3920 5494 w (make) 4089 5494 w 10 /Helvetica f (y) 4339 5494 w 10 /Times-Roman f (point) 4420 5494 w (to) 4657 5494 w (an) 4766 5494 w (ele\255) 4891 5494 w (ment of) 720 5614 w 10 /Helvetica f (x) 1056 5614 w 10 /Times-Roman f (by either of) 1131 5614 w 10 /Helvetica f (y) 1080 5784 w (=) 1165 5784 w (&x[0];) 1258 5784 w (y) 1080 5904 w (=) 1165 5904 w (x;) 1258 5904 w 10 /Times-Roman f (Since) 720 6074 w 10 /Helvetica f (x) 970 6074 w 10 /Times-Roman f (is the address of) 1045 6074 w 10 /Helvetica f (x[0]) 1719 6074 w 10 /Times-Roman f (this is legal and consistent.) 1906 6074 w (Now) 970 6230 w 10 /Helvetica f (`) 1192 6230 w 14 /Helvetica f (*) 1214 6279 w 10 /Helvetica f (y') 1269 6230 w 10 /Times-Roman f (gives) 1366 6230 w 10 /Helvetica f (x[0]) 1605 6230 w 16 /Helvetica f (.) 1767 6230 w 10 /Times-Roman f (More importantly,) 1862 6230 w 14 /Helvetica f (*) 1080 6449 w 10 /Helvetica f (\(y+1\)) 1135 6400 w (gives) 1440 6400 w (x[1]) 1709 6400 w 14 /Helvetica f (*) 1080 6569 w 10 /Helvetica f (\(y+i\)) 1135 6520 w (gives) 1440 6520 w (x[i]) 1709 6520 w 10 /Times-Roman f (and the sequence) 720 6690 w 10 /Helvetica f (y) 1440 6860 w (=) 1525 6860 w (&x[0];) 1618 6860 w (y) 1440 6980 w 10 /Times-Roman f (++) 1490 6980 w 10 /Helvetica f (;) 1602 6980 w cleartomark showpage saveobj restore %%EndPage: 12 12 %%Page: 13 13 /saveobj save def mark 13 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 13 \255) 2952 360 w (leaves) 720 840 w 10 /Helvetica f (y) 997 840 w 10 /Times-Roman f (pointing at) 1072 840 w 10 /Helvetica f (x[1]) 1531 840 w 16 /Helvetica f (.) 1693 840 w 10 /Times-Roman f (Let's) 970 996 w (use) 1204 996 w (pointers) 1366 996 w (in) 1718 996 w (a) 1826 996 w (function) 1900 996 w 10 /Helvetica f (length) 2266 996 w 10 /Times-Roman f (that) 2570 996 w (computes) 2750 996 w (how) 3163 996 w (long) 3365 996 w (a) 3573 996 w (character) 3647 996 w (array) 4041 996 w (is.) 4275 996 w (Remember) 4422 996 w (that) 4890 996 w (by) 720 1116 w (convention) 847 1116 w (all) 1318 1116 w (character) 1445 1116 w (arrays) 1835 1116 w (are) 2104 1116 w (terminated) 2251 1116 w (with) 2704 1116 w (a) 2908 1116 w (`\\0'.) 2978 1116 w (\(And) 3198 1116 w (if) 3429 1116 w (they) 3516 1116 w (aren't,) 3714 1116 w (this) 3997 1116 w (program) 4168 1116 w (will) 4532 1116 w (blow) 4714 1116 w (up) 4940 1116 w (inevitably.\)) 720 1236 w (The old way:) 1228 1236 w 10 /Helvetica f (length\(s\)) 1080 1406 w (char) 1185 1526 w (s[) 1415 1526 w (];) 1528 1526 w ({) 1619 1526 w (int) 1440 1646 w (n;) 1581 1646 w (for\() 1440 1766 w (n=0;) 1625 1766 w (s[n]) 1858 1766 w (!=) 2055 1766 w 10 /S f (\242) 2176 1766 w 10 /Helvetica f (\\0) 2201 1766 w 10 /S f (\242) 2285 1766 w 10 /Helvetica f (;) 2310 1766 w (\)) 2373 1766 w (n) 1800 1886 w 10 /Times-Roman f (++) 1856 1886 w 10 /Helvetica f (;) 1968 1886 w (return\(n\);) 1440 2006 w (}) 1080 2126 w 10 /Times-Roman f (Rewriting with pointers gives) 720 2296 w 10 /Helvetica f (length\(s\)) 1080 2466 w (char) 1185 2586 w 14 /Helvetica f (*) 1415 2635 w 10 /Helvetica f (s;) 1470 2586 w ({) 1583 2586 w (int) 1440 2706 w (n;) 1581 2706 w (for\() 1440 2826 w (n=0;) 1625 2826 w 14 /Helvetica f (*) 1858 2875 w 10 /Helvetica f (s) 1913 2826 w (!=) 1998 2826 w 10 /S f (\242) 2119 2826 w 10 /Helvetica f (\\0) 2144 2826 w 10 /S f (\242) 2228 2826 w 10 /Helvetica f (;) 2253 2826 w (s) 2316 2826 w 10 /Times-Roman f (++) 2366 2826 w 10 /Helvetica f (\)) 2513 2826 w (n) 1800 2946 w 10 /Times-Roman f (++) 1856 2946 w 10 /Helvetica f (;) 1968 2946 w (return\(n\);) 1440 3066 w (}) 1080 3186 w 10 /Times-Roman f (You) 720 3356 w (can) 919 3356 w (now) 1084 3356 w (see) 1283 3356 w (why) 1437 3356 w (we) 1636 3356 w (have) 1779 3356 w (to) 1994 3356 w (say) 2099 3356 w (what) 2259 3356 w (kind) 2480 3356 w (of) 2685 3356 w (thing) 2795 3356 w 10 /Helvetica f (s) 3031 3356 w 10 /Times-Roman f (points) 3108 3356 w (to) 3381 3356 w 10 /S f (_) 3487 3356 w 10 /Times-Roman f (if) 3565 3356 w (we're) 3654 3356 w (to) 3908 3356 w (increment) 4014 3356 w (it) 4441 3356 w (with) 4525 3356 w 10 /Helvetica f (s) 4734 3356 w 10 /Times-Roman f (++) 4784 3356 w (we) 4924 3356 w (have to increment it by the right amount.) 720 3476 w (The pointer version is more efficient \(this is almost always true\) but even 2000 more compact is) 970 3632 w 10 /Helvetica f (for\() 1440 3802 w (n=0;) 1625 3802 w 14 /Helvetica f (*) 1858 3851 w 10 /Helvetica f (s) 1913 3802 w 10 /Times-Roman f (++) 1963 3802 w 10 /Helvetica f (!=) 2110 3802 w 10 /S f (\242) 2231 3802 w 10 /Helvetica f (\\0) 2256 3802 w 10 /S f (\242) 2340 3802 w 10 /Helvetica f (;) 2365 3802 w (n) 2428 3802 w 10 /Times-Roman f (++) 2484 3802 w 10 /Helvetica f (\);) 2631 3802 w 10 /Times-Roman f (The) 720 3972 w 10 /Helvetica f (`) 903 3972 w 14 /Helvetica f (*) 925 4021 w 10 /Helvetica f (s') 980 3972 w 10 /Times-Roman f (returns a character; the) 1077 3972 w 10 /Helvetica f (`) 2015 3972 w 10 /Times-Roman f (++) 2037 3972 w 10 /Helvetica f (') 2149 3972 w 10 /Times-Roman f (increments the pointer so we'll get the next character next time around.) 2196 3972 w (As) 720 4092 w (you) 859 4092 w (can) 1036 4092 w (see,) 1201 4092 w (as) 1380 4092 w (we) 1490 4092 w (make) 1633 4092 w (things) 1876 4092 w (more) 2148 4092 w (efficient,) 2380 4092 w (we) 2764 4092 w (also) 2907 4092 w (make) 3095 4092 w (them) 3338 4092 w (less) 3565 4092 w (clear.) 3742 4092 w (But) 4012 4092 w 10 /Helvetica f (`) 4187 4092 w 14 /Helvetica f (*) 4209 4141 w 10 /Helvetica f (s) 4264 4092 w 10 /Times-Roman f (++) 4314 4092 w 10 /Helvetica f (') 4426 4092 w 10 /Times-Roman f (is) 4475 4092 w (an) 4569 4092 w (idiom) 4690 4092 w (so) 4951 4092 w (common that you have to know it.) 720 4212 w (Going a step further, here's our function) 970 4368 w 10 /Helvetica f (strcopy) 2608 4368 w 10 /Times-Roman f (that copies a character array) 2956 4368 w 10 /Helvetica f (s) 4101 4368 w 10 /Times-Roman f (to another) 4176 4368 w 10 /Helvetica f (t) 4606 4368 w 16 /Helvetica f (.) 4634 4368 w 10 /Helvetica f (strcopy\(s,t\)) 1080 4538 w (char) 1185 4658 w 14 /Helvetica f (*) 1415 4707 w 10 /Helvetica f (s,) 1470 4658 w 14 /Helvetica f (*) 1583 4707 w 10 /Helvetica f (t;) 1638 4658 w ({) 1729 4658 w (while\() 1440 4778 w 14 /Helvetica f (*) 1701 4827 w 10 /Helvetica f (t) 1756 4778 w 10 /Times-Roman f (++) 1784 4778 w 10 /Helvetica f (=) 1931 4778 w 14 /Helvetica f (*) 2024 4827 w 10 /Helvetica f (s) 2079 4778 w 10 /Times-Roman f (++) 2129 4778 w 10 /Helvetica f (\);) 2241 4778 w (}) 1080 4898 w 10 /Times-Roman f (We) 720 5068 w (have) 886 5068 w (omitted) 1102 5068 w (the) 1436 5068 w (test) 1586 5068 w (against) 1753 5068 w (`\\0',) 2064 5068 w (because) 2261 5068 w (`\\0') 2605 5068 w (is) 2778 5068 w (identically) 2874 5068 w (zero;) 3325 5068 w (you) 3553 5068 w (will) 3732 5068 w (often) 3917 5068 w (see) 4151 5068 w (the) 4307 5068 w (code) 4458 5068 w (this) 4675 5068 w (way.) 4849 5068 w (\(You) 720 5188 w 10 /Times-Italic f (must) 950 5188 w 10 /Times-Roman f (have a space after the `=': see section 25.\)) 1164 5188 w (For arguments to a function, and there only, the declarations) 970 5344 w 10 /Helvetica f (char) 1080 5514 w (s[) 1310 5514 w (];) 1423 5514 w (char) 1080 5634 w 14 /Helvetica f (*) 1310 5683 w 10 /Helvetica f (s;) 1365 5634 w 10 /Times-Roman f (are equivalent ) 720 5804 w 10 /S f (_) 1307 5804 w 10 /Times-Roman f (a pointer to a type, or an array of unspecified size of that type, are the same thing.) 1382 5804 w (If this all seems mysterious, copy these forms until they become second nature.) 970 5960 w (You don't often) 4188 5960 w (need) 4852 5960 w (anything more complicated.) 720 6080 w 10 /Helvetica f (17. Function Arguments) 720 6320 w 10 /Times-Roman f (Look) 970 6476 w (back) 1213 6476 w (at) 1433 6476 w (the) 1537 6476 w (function) 1691 6476 w 10 /Helvetica f (strcopy) 2059 6476 w 10 /Times-Roman f (in) 2414 6476 w (the) 2525 6476 w (previous) 2680 6476 w (section.) 3057 6476 w (We) 3423 6476 w (passed) 3594 6476 w (it) 3893 6476 w (two) 3982 6476 w (string) 4165 6476 w (names) 4426 6476 w (as) 4714 6476 w (argu\255) 4830 6476 w (ments,) 720 6596 w (then) 1012 6596 w (proceeded) 1212 6596 w (to) 1649 6596 w (clobber) 1755 6596 w (both) 2082 6596 w (of) 2288 6596 w (them) 2399 6596 w (by) 2627 6596 w (incrementation.) 2755 6596 w (So) 3432 6596 w (how) 3566 6596 w (come) 3766 6596 w (we) 4010 6596 w (don't) 4154 6596 w (lose) 4392 6596 w (the) 4580 6596 w (original) 4729 6596 w (strings in the function that called) 720 6716 w 10 /Helvetica f (strcopy?) 2061 6716 w 10 /Times-Roman f (As) 970 6872 w (we) 1117 6872 w (said) 1269 6872 w (before,) 1466 6872 w (C) 1781 6872 w (is) 1884 6872 w (a) 1987 6872 w (``call) 2067 6872 w (by) 2313 6872 w (value'') 2450 6872 w (language:) 2769 6872 w (when) 3194 6872 w (you) 3447 6872 w (make) 3634 6872 w (a) 3887 6872 w (function) 3968 6872 w (call) 4338 6872 w (like) 4519 6872 w 10 /Helvetica f (f\(x\),) 4709 6872 w 10 /Times-Roman f (the) 4918 6872 w 10 /Times-Italic f (value) 720 6992 w 10 /Times-Roman f (of) 972 6992 w 10 /Helvetica f (x) 1094 6992 w 10 /Times-Roman f (is) 1180 6992 w (passed,) 1283 6992 w (not) 1610 6992 w (its) 1774 6992 w (address.) 1905 6992 w (So) 2290 6992 w (there's) 2432 6992 w (no) 2739 6992 w (way) 2875 6992 w (to) 3077 6992 w 10 /Times-Italic f (alter) 3191 6992 w 10 /Helvetica f (x) 3419 6992 w 10 /Times-Roman f (from) 3505 6992 w (inside) 3735 6992 w 10 /Helvetica f (f) 4013 6992 w 16 /Helvetica f (.) 4041 6992 w 10 /Times-Roman f (If) 4147 6992 w 10 /Helvetica f (x) 4252 6992 w 10 /Times-Roman f (is) 4338 6992 w (an) 4441 6992 w (array) 4570 6992 w 10 /Helvetica f (\(char) 4812 6992 w (x[10]\)) 720 7112 w 10 /Times-Roman f (this) 999 7112 w (isn't) 1172 7112 w (a) 1378 7112 w (problem,) 1450 7112 w (because) 1836 7112 w 10 /Helvetica f (x) 2182 7112 w 10 /Times-Italic f (is) 2261 7112 w 10 /Times-Roman f (an) 2357 7112 w (address) 2480 7112 w (anyway,) 2808 7112 w (and) 3172 7112 w (you're) 3345 7112 w (not) 3634 7112 w (trying) 3791 7112 w (to) 4059 7112 w (change) 4166 7112 w (it,) 4477 7112 w (just) 4587 7112 w (what) 4761 7112 w (it) 4984 7112 w (addresses.) 720 7232 w (This) 1184 7232 w (is) 1393 7232 w (why) 1491 7232 w 10 /Helvetica f (strcopy) 1697 7232 w 10 /Times-Roman f (works) 2051 7232 w (as) 2326 7232 w (it) 2440 7232 w (does.) 2527 7232 w (And) 2791 7232 w (it's) 2994 7232 w (convenient) 3153 7232 w (not) 3622 7232 w (to) 3781 7232 w (have) 3890 7232 w (to) 4109 7232 w (worry) 4218 7232 w (about) 4487 7232 w (making) 4740 7232 w cleartomark showpage saveobj restore %%EndPage: 13 13 %%Page: 14 14 /saveobj save def mark 14 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 14 \255) 2952 360 w (temporary copies of the input arguments.) 720 840 w (But what if) 970 996 w 10 /Helvetica f (x) 1448 996 w 10 /Times-Roman f (is a scalar and you do) 1523 996 w (want) 2411 996 w (to) 2631 996 w (change) 2735 996 w (it?) 3043 996 w (In) 3194 996 w (that) 3303 996 w (case,) 3479 996 w (you) 3701 996 w (have) 3877 996 w (to) 4091 996 w (pass) 4195 996 w (the) 4393 996 w 10 /Times-Italic f (address) 4541 996 w 10 /Times-Roman f (of) 4878 996 w 10 /Helvetica f (x) 4990 996 w 10 /Times-Roman f (to) 720 1116 w 10 /Helvetica f (f,) 826 1116 w 10 /Times-Roman f (and then use it as a pointer.) 907 1116 w (Thus for example, to interchange two integers, we must write) 2047 1116 w 10 /Helvetica f (flip\(x,) 1080 1286 w (y\)) 1354 1286 w (int) 1185 1406 w 14 /Helvetica f (*) 1326 1455 w 10 /Helvetica f (x,) 1381 1406 w 14 /Helvetica f (*) 1494 1455 w 10 /Helvetica f (y;) 1549 1406 w ({) 1662 1406 w (int) 1440 1526 w (temp;) 1581 1526 w (temp) 1440 1646 w (=) 1698 1646 w 14 /Helvetica f (*) 1791 1695 w 10 /Helvetica f (x;) 1846 1646 w 14 /Helvetica f (*) 1440 1815 w 10 /Helvetica f (x) 1495 1766 w (=) 1580 1766 w 14 /Helvetica f (*) 1673 1815 w 10 /Helvetica f (y;) 1728 1766 w 14 /Helvetica f (*) 1440 1935 w 10 /Helvetica f (y) 1495 1886 w (=) 1580 1886 w (temp;) 1673 1886 w (}) 1080 2006 w 10 /Times-Roman f (and to call) 720 2176 w 10 /Helvetica f ( 2000 flip,) 1164 2176 w 10 /Times-Roman f (we have to pass the addresses of the variables:) 1345 2176 w 10 /Helvetica f (flip) 1080 2346 w (\(&a,) 1243 2346 w (&b\);) 1462 2346 w (18. Multiple Levels of Pointers; Program Arguments) 720 2636 w 10 /Times-Roman f (When) 970 2792 w (a) 1235 2792 w (C) 1306 2792 w (program) 1400 2792 w (is) 1765 2792 w (called,) 1859 2792 w (the) 2149 2792 w (arguments) 2298 2792 w (on) 2741 2792 w (the) 2868 2792 w (command) 3017 2792 w (line) 3438 2792 w (are) 3615 2792 w (made) 3763 2792 w (available) 4006 2792 w (to) 4393 2792 w (the) 4498 2792 w (main) 4647 2792 w (pro\255) 4874 2792 w (gram) 720 2912 w (as) 953 2912 w (an) 1063 2912 w (argument) 1184 2912 w (count) 1588 2912 w 10 /Helvetica f (argc) 1840 2912 w 10 /Times-Roman f (and) 2062 2912 w (an) 2233 2912 w (array) 2354 2912 w (of) 2585 2912 w (character) 2695 2912 w (strings) 3086 2912 w 10 /Helvetica f (argv) 3383 2912 w 10 /Times-Roman f (containing) 3605 2912 w (the) 4054 2912 w (arguments.) 4203 2912 w (Manipu\255) 4696 2912 w (lating these arguments is one of the) 720 3032 w (most) 2161 3032 w (common) 2382 3032 w (uses) 2758 3032 w (of) 2956 3032 w (multiple) 3065 3032 w (levels) 3425 3032 w (of) 3684 3032 w (pointers) 3793 3032 w (\(``pointer) 4141 3032 w (to) 4549 3032 w (pointer) 4653 3032 w (to) 4962 3032 w (...''\).) 720 3152 w (By convention,) 969 3152 w 10 /Helvetica f (argc) 1608 3152 w 10 /Times-Roman f (is greater than zero; the first argument \(in) 1828 3152 w 10 /Helvetica f (argv[0]\)) 3516 3152 w 10 /Times-Roman f (is the command name itself.) 3881 3152 w (Here is a program that simply echoes its arguments.) 970 3308 w 10 /Helvetica f (main\(argc,) 1080 3478 w (argv\)) 1588 3478 w (int) 1185 3598 w (argc;) 1326 3598 w (char) 1185 3718 w 14 /Helvetica f (**) 1415 3767 w 10 /Helvetica f (argv;) 1525 3718 w ({) 1783 3718 w (int) 1440 3838 w (i;) 1581 3838 w (for\() 1440 3958 w (i=1;) 1625 3958 w (i) 1824 3958 w (<) 1881 3958 w (argc;) 1974 3958 w (i) 2232 3958 w 10 /Times-Roman f (++) 2254 3958 w 10 /Helvetica f (\)) 2401 3958 w (printf\("%s) 1800 4078 w (",) 2266 4078 w (argv[i]\);) 2365 4078 w (putchar\() 1440 4198 w 10 /S f (\242) 1808 4198 w 10 /Helvetica f (\\n) 1833 4198 w 10 /S f (\242) 1917 4198 w 10 /Helvetica f (\);) 1942 4198 w (}) 1080 4318 w 10 /Times-Roman f (Step) 720 4488 w (by) 924 4488 w (step:) 1050 4488 w 10 /Helvetica f (main) 1268 4488 w 10 /Times-Roman f (is) 1511 4488 w (called) 1604 4488 w (with) 1868 4488 w (two) 2073 4488 w (arguments,) 2250 4488 w (the) 2718 4488 w (argument) 2867 4488 w (count) 3271 4488 w (and) 3520 4488 w (the) 3691 4488 w (array) 3840 4488 w (of) 4071 4488 w (arguments.) 4181 4488 w 10 /Helvetica f (argv) 4680 4488 w 10 /Times-Roman f (is) 4902 4488 w (a) 4996 4488 w (pointer) 720 4608 w (to) 1033 4608 w (an) 1141 4608 w (array,) 1265 4608 w (whose) 1524 4608 w (individual) 1809 4608 w (elements) 2245 4608 w (are) 2630 4608 w (pointers) 2781 4608 w (to) 3132 4608 w (arrays) 3239 4608 w (of) 3511 4608 w (characters.) 3623 4608 w (The) 4105 4608 w (zeroth) 4289 4608 w (argument) 4567 4608 w (is) 4973 4608 w (the) 720 4728 w (name) 874 4728 w (of) 1122 4728 w (the) 1237 4728 w (command) 1391 4728 w (itself,) 1817 4728 w (so) 2074 4728 w (we) 2195 4728 w (start) 2343 4728 w (to) 2547 4728 w (print) 2657 4728 w (with) 2878 4728 w (the) 3089 4728 w (first) 3244 4728 w (argument,) 3438 4728 w (until) 3873 4728 w (we've) 4090 4728 w (printed) 4366 4728 w (them) 4682 4728 w (all.) 4915 4728 w (Each) 720 4848 w 10 /Helvetica f (argv[i]) 947 4848 w 10 /Times-Roman f (is a character array, so we use a) 1245 4848 w 10 /Helvetica f (`%s') 2534 4848 w 10 /Times-Roman f (in the) 2742 4848 w 10 /Helvetica f (printf) 2995 4848 w 16 /Helvetica f (.) 3218 4848 w 10 /Times-Roman f (You will sometimes see the declaration of) 970 5004 w 10 /Helvetica f (argv) 2679 5004 w 10 /Times-Roman f (written as) 2899 5004 w 10 /Helvetica f (char) 1080 5174 w 14 /Helvetica f (*) 1310 5223 w 10 /Helvetica f (argv[) 1365 5174 w (];) 1623 5174 w 10 /Times-Roman f (which) 720 5344 w (is) 1003 5344 w (equivalent.) 1109 5344 w (But) 1614 5344 w (we) 1798 5344 w (can't) 1953 5344 w (use) 2191 5344 w 10 /Helvetica f (char) 2367 5344 w (argv[) 2605 5344 w (][) 2871 5344 w (],) 2970 5344 w 10 /Times-Roman f (because) 3066 5344 w (both) 3421 5344 w (dimensions) 3639 5344 w (are) 4135 5344 w (variable) 4296 5344 w (and) 4657 5344 w (there) 4841 5344 w (would be no way to figure out how big the array is.) 720 5464 w (Here's) 970 5620 w (a) 1267 5620 w (bigger) 1343 5620 w (example) 1630 5620 w (using) 2000 5620 w 10 /Helvetica f (argc) 2252 5620 w 10 /Times-Roman f (and) 2479 5620 w 10 /Helvetica f (argv) 2658 5620 w 16 /Helvetica f (.) 2853 5620 w 10 /Times-Roman f (A) 2955 5620 w (common) 3060 5620 w (convention) 3443 5620 w (in) 3920 5620 w (C) 4031 5620 w (programs) 4131 5620 w (is) 4541 5620 w (that) 4641 5620 w (if) 4824 5620 w (the) 4918 5620 w (first) 720 5740 w (argument) 911 5740 w (is) 1318 5740 w (`) 1415 5740 w 10 /S f (-) 1448 5740 w 10 /Times-Roman f (',) 1503 5740 w (it) 1591 5740 w (indicates) 1677 5740 w (a) 2062 5740 w (flag) 2136 5740 w (of) 2321 5740 w (some) 2434 5740 w (sort.) 2675 5740 w (For) 2905 5740 w (example,) 3074 5740 w (suppose) 3467 5740 w (we) 3819 5740 w (want) 3965 5740 w (a) 4189 5740 w (program) 4263 5740 w (to) 4631 5740 w (be) 4739 5740 w (call\255) 4863 5740 w (able as) 720 5860 w 10 /Helvetica f (prog) 1080 6030 w 10 /S f (-) 1316 6030 w 10 /Helvetica f (abc) 1371 6030 w (arg1) 1568 6030 w (arg2) 1804 6030 w 16 /Helvetica f (...) 2040 6030 w 10 /Times-Roman f (where the `) 720 6200 w 10 /S f (-) 1168 6200 w 10 /Times-Roman f (' argument is optional; if it is present, it may be followed by any combination of a, b, and c.) 1223 6200 w 10 /Helvetica f (main\(argc,) 1080 6370 w (argv\)) 1588 6370 w (int) 1185 6490 w (argc;) 1326 6490 w (char) 1185 6610 w 14 /Helvetica f (**) 1415 6659 w 10 /Helvetica f (argv;) 1525 6610 w ({) 1783 6610 w 16 /Helvetica f (...) 1440 6730 w 10 /Helvetica f (aflag) 1440 6850 w (=) 1693 6850 w (bflag) 1786 6850 w (=) 2039 6850 w (cflag) 2132 6850 w (=) 2414 6850 w (0;) 2507 6850 w (if\() 1440 6970 w (argc) 1558 6970 w (>) 1788 6970 w (1) 1881 6970 w (&&) 1972 6970 w (argv[1][0]) 2141 6970 w 10 /Times-Roman f (==) 2595 6970 w 10 /S f (\242-\242) 2742 6970 w 10 /Helvetica f (\)) 2882 6970 w ({) 2950 6970 w (for\() 1800 7090 w (i=1;) 1985 7090 w (\(c=argv[1][i]\)) 2184 7090 w (!=) 2778 7090 w 10 /S f (\242) 2899 7090 w 10 /Helvetica f (\\0) 2924 7090 w 10 /S f (\242) 3008 7090 w 10 /Helvetica f (;) 3033 7090 w (i) 3096 7090 w 10 /Times-Roman f (++) 3118 7090 w 10 /Helvetica f (\)) 3265 7090 w (if\() 2160 7210 w (c) 2278 7210 w 10 /Times-Roman f (==) 2328 7210 w 10 /S f (\242) 2440 7210 w 10 /Helvetica f (a) 2465 7210 w 10 /S f (\242) 2521 7210 w 10 /Helvetica f (\)) 2581 7210 w cleartomark showpage saveobj restore %%EndPage: 14 14 %%Page: 15 15 /saveobj save def mark 15 pagesetup 10 /Helvetica f (C ) 720 360 w (Tutorial) 827 360 w 10 /S f (-) 2914 360 w 10 /Helvetica f (15 ) 3004 360 w 10 /S f (-) 3151 360 w 10 /Helvetica f (aflag) 2520 840 w 10 /Times-Roman f (++) 2738 840 w 10 /Helvetica f (;) 2850 840 w (else) 2160 960 w (if\() 2379 960 w (c) 2497 960 w 10 /Times-Roman f (==) 2547 960 w 10 /S f (\242) 2659 960 w 10 /Helvetica f (b) 2684 960 w 10 /S f (\242) 2740 960 w 10 /Helvetica f (\)) 2800 960 w (bflag) 2520 1080 w 10 /Times-Roman f (++) 2738 1080 w 10 /Helvetica f (;) 2850 1080 w (else) 2160 1200 w (if\() 2379 1200 w (c) 2497 1200 w 10 /Times-Roman f (==) 2547 1200 w 10 /S f (\242) 2659 1200 w 10 /Helvetica f (c) 2684 1200 w 10 /S f (\242) 2734 1200 w 10 /Helvetica f (\)) 2794 1200 w (cflag) 2520 1320 w 10 /Times-Roman f (++) 2732 1320 w 10 /Helvetica f (;) 2844 2000 1320 w (else) 2160 1440 w (printf\("%c?\\n",) 2520 1560 w (c\);) 3190 1560 w 10 /S f (--) 1800 1680 w 10 /Helvetica f (argc;) 1910 1680 w 10 /Times-Roman f (++) 1800 1800 w 10 /Helvetica f (argv;) 1912 1800 w (}) 1440 1920 w 16 /Helvetica f (...) 1440 2040 w 10 /Times-Roman f (There) 970 2246 w (are) 1229 2246 w (several) 1377 2246 w (things) 1686 2246 w (worth) 1958 2246 w (noticing) 2218 2246 w (about) 2573 2246 w (this) 2822 2246 w (code.) 2994 2246 w (First,) 3259 2246 w (there) 3495 2246 w (is) 3721 2246 w (a) 3815 2246 w (real) 3887 2246 w (need) 4064 2246 w (for) 4280 2246 w (the) 4424 2246 w (left\255to\255right) 4574 2246 w (evaluation) 720 2366 w (that) 1175 2366 w (&&) 1364 2366 w (provides;) 1559 2366 w (we) 1970 2366 w (don't) 2125 2366 w (want) 2375 2366 w (to) 2608 2366 w (look) 2725 2366 w (at) 2942 2366 w 10 /Helvetica f (argv[1]) 3056 2366 w 10 /Times-Roman f (unless) 3402 2366 w (we) 3691 2366 w (know) 3846 2366 w (it's) 4107 2366 w (there.) 4274 2366 w (Second,) 4561 2366 w (the) 4918 2366 w (statements) 720 2486 w 10 /S f (--) 1440 2656 w 10 /Helvetica f (argc;) 1550 2656 w 10 /Times-Roman f (++) 1440 2776 w 10 /Helvetica f (argv;) 1552 2776 w 10 /Times-Roman f (let) 720 2946 w (us) 846 2946 w (march) 961 2946 w (along) 1236 2946 w (the) 1484 2946 w (argument) 1632 2946 w (list) 2035 2946 w (by) 2184 2946 w (one) 2310 2946 w (position,) 2480 2946 w (so) 2854 2946 w (we) 2970 2946 w (can) 3113 2946 w (skip) 3278 2946 w (over) 3472 2946 w (the) 3676 2946 w (flag) 3825 2946 w (argument) 4007 2946 w (as) 4411 2946 w (if) 4521 2946 w (it) 4609 2946 w (had) 4692 2946 w (nev\255) 4863 2946 w (er) 720 3066 w (existed) 827 3066 w 10 /S f (_) 1140 3066 w 10 /Times-Roman f (the) 1220 3066 w (rest) 1372 3066 w (of) 1546 3066 w (the) 1659 3066 w (program) 1811 3066 w (is) 2179 3066 w (independent) 2276 3066 w (of) 2794 3066 w (whether) 2907 3066 w (or) 3258 3066 w (not) 3371 3066 w (there) 3529 3066 w (was) 3758 3066 w (a) 3942 3066 w (flag) 4015 3066 w (argument.) 4199 3066 w (This) 4655 3066 w (only) 4862 3066 w (works because) 720 3186 w 10 /Helvetica f (argv) 1332 3186 w 10 /Times-Roman f (is a pointer which can be incremented.) 1552 3186 w 10 /Helvetica f (19. The Switch Statement; Break; Continue) 720 3426 w 10 /Times-Roman f (The) 970 3582 w 10 /Helvetica f (switch) 1159 3582 w 10 /Times-Roman f (statement) 1468 3582 w (can) 1882 3582 w (be) 2051 3582 w (used) 2176 3582 w (to) 2390 3582 w (replace) 2499 3582 w (the) 2817 3582 w (multi\255way) 2970 3582 w (test) 3413 3582 w (we) 3584 3582 w (used) 3732 3582 w (in) 3947 3582 w (the) 4057 3582 w (last) 4211 3582 w (example.) 4382 3582 w (When) 4802 3582 w (the tests are like this:) 720 3702 w 10 /Helvetica f (if\() 1080 3872 w (c) 1198 3872 w 10 /Times-Roman f (==) 1283 3872 w 10 /S f (\242) 1430 3872 w 10 /Helvetica f (a) 1455 3872 w 10 /S f (\242) 1511 3872 w 10 /Helvetica f (\)) 1571 3872 w 16 /Helvetica f (...) 1639 3872 w 10 /Helvetica f (else) 1080 3992 w (if\() 1299 3992 w (c) 1417 3992 w 10 /Times-Roman f (==) 1502 3992 w 10 /S f (\242) 1649 3992 w 10 /Helvetica f (b) 1674 3992 w 10 /S f (\242) 1730 3992 w 10 /Helvetica f (\)) 1790 3992 w 16 /Helvetica f (...) 1858 3992 w 10 /Helvetica f (else) 1080 4112 w (if\() 1299 4112 w (c) 1417 4112 w 10 /Times-Roman f (==) 1502 4112 w 10 /S f (\242) 1649 4112 w 10 /Helvetica f (c) 1674 4112 w 10 /S f (\242) 1724 4112 w 10 /Helvetica f (\)) 1784 4112 w 16 /Helvetica f (...) 1852 4112 w 10 /Helvetica f (else) 1080 4232 w 16 /Helvetica f (...) 1299 4232 w 10 /Times-Roman f (testing) 720 4402 w (a) 1020 4402 w (value) 1097 4402 w (against) 1346 4402 w (a) 1662 4402 w (series) 1740 4402 w (of) 2001 4402 w 10 /Times-Italic f (constants,) 2118 4402 w 10 /Times-Roman f (the) 2555 4402 w (switch) 2711 4402 w (statement) 3006 4402 w (is) 3423 4402 w (often) 3524 4402 w (clearer) 3763 4402 w (and) 4067 4402 w (usually) 4245 4402 w (gives) 4568 4402 w (better) 4813 4402 w (code.) 720 4522 w (Use it like this:) 983 4522 w 10 /Helvetica f (switch\() 1080 4692 w (c) 1426 4692 w (\)) 1511 4692 w ({) 1579 4692 w (case) 1080 4932 w 10 /S f (\242) 1327 4932 w 10 /Helvetica f (a) 1352 4932 w 10 /S f (\242) 1408 4932 w 10 /Helvetica f (:) 1433 4932 w (aflag) 1440 5052 w 10 /Times-Roman f (++) 1658 5052 w 10 /Helvetica f (;) 1770 5052 w (break;) 1440 5172 w (case) 1080 5292 w 10 /S f (\242) 1327 5292 w 10 /Helvetica f (b) 1352 5292 w 10 /S f (\242) 1408 5292 w 10 /Helvetica f (:) 1433 5292 w (bflag) 1440 5412 w 10 /Times-Roman f (++) 1658 5412 w 10 /Helvetica f (;) 1770 5412 w (break;) 1440 5532 w (case) 1080 5652 w 10 /S f (\242) 1327 5652 w 10 /Helvetica f (c) 1352 5652 w 10 /S f (\242) 1402 5652 w 10 /Helvetica f (:) 1427 5652 w (cflag) 1440 5772 w 10 /Times-Roman f (++) 1652 5772 w 10 /Helvetica f (;) 1764 5772 w (break;) 1440 5892 w (default:) 1080 6012 w (printf\("%c?\\n",) 1440 6132 w (c\);) 2110 6132 w (break;) 1440 6252 w (}) 1080 6372 w 10 /Times-Roman f (The) 720 6542 w 10 /Helvetica f (case) 904 6542 w 10 /Times-Roman f (statements) 1142 6542 w (label) 1590 6542 w (the) 1810 6542 w (various) 1958 6542 w (actions) 2278 6542 w (we) 2587 6542 w (want;) 2729 6542 w 10 /Helvetica f (default) 2980 6542 w 10 /Times-Roman f (gets) 3308 6542 w (done) 3495 6542 w (if) 3715 6542 w (none) 3802 6542 w (of) 4022 6542 w (the) 4131 6542 w (other) 4279 6542 w (cases) 4511 6542 w (are) 4748 6542 w (sat\255) 4896 6542 w (isfied.) 720 6662 w (\(A) 1017 6662 w 10 /Helvetica f (default) 1150 6662 w 10 /Times-Roman f (is optional; if it isn't there, and none of the cases match, you just fall out the bottom.\)) 1477 6662 w (The) 970 6818 w 10 /Helvetica f (break) 1161 6818 w 10 /Times-Roman f (statement) 1445 6818 w (in) 1862 6818 w (this) 1974 6818 w (example) 2153 6818 w (is) 2525 6818 w (new.) 2626 6818 w (It) 2876 6818 w (is) 2971 6818 w (there) 3072 6818 w (because) 3305 6818 w (the) 3654 6818 w (cases) 3810 6818 w (are) 4054 6818 w (just) 4209 6818 w (labels,) 4388 6818 w (and) 4680 6818 w (after) 4858 6818 w (you) 720 6938 w (do) 901 6938 w (one) 1032 6938 w (of) 1207 6938 w (them,) 1321 6938 w (you) 1577 6938 w 10 /Times-Italic f (fall) 1758 6938 w (through) 1923 6938 w 10 /Times-Roman f (to) 2271 6938 w (the) 2380 6938 w (next) 2533 6938 w (unless) 2736 6938 w (you) 3017 6938 w (take) 3197 6938 w (some) 3393 6938 w (explicit) 3634 6938 w (action) 3964 6938 w (to) 4238 6938 w (escape.) 4346 6938 w (This) 4691 6938 w (is) 4899 6938 w (a) 4996 6938 w (mixed) 720 7058 w (blessing.) 998 7058 w (On) 1404 7058 w (the) 1554 7058 w (positive) 1704 7058 w (side,) 2049 7058 w (you) 2263 7058 w (can) 2441 7058 w (have) 2607 7058 w (multiple) 2823 7058 w (cases) 3185 7058 w (on) 3423 7058 w (a) 3551 7058 w (single) 3623 7058 w (statement;) 3891 7058 w (we) 4331 7058 w (might) 4476 7058 w (want) 4739 7058 w (to) 4962 7058 w (allow both upper and lower case letters in our flag field, so we could say) 720 7178 w cleartomark showpage saveobj restore %%EndPage: 15 15 %%Page: 16 16 /saveobj save def mark 16 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 16 \255) 2952 360 w 10 /Helvetica f (case) 1080 840 w 10 /S f (\242) 1327 840 w 10 /Helvetica f (a) 1352 840 w 10 /S f (\242) 1408 840 w 10 /Helvetica f (:) 1433 840 w (case) 1531 840 w 10 /S f (\242) 1778 840 w 10 /Helvetica f (A) 1803 840 w 10 /S f (\242) 1870 840 w 10 /Helvetica f (:) 1895 840 w 16 /Helvetica f (...) 2160 840 w 10 /Helvetica f (case) 1080 1010 w 10 /S f (\242) 1327 1010 w 10 /Helvetica f (b) 1352 1010 w 10 /S f (\242) 1408 1010 w 10 /Helvetica f (:) 1433 1010 w (case) 1531 1010 w 10 /S f (\242) 1778 1010 w 10 /Helvetica f (B) 1803 1010 w 10 /S f (\242) 1870 1010 w 10 /Helvetica f (:) 1895 1010 w 16 /Helvetica f (...) 2160 1010 w 10 /Helvetica f (etc) 1115 1130 w 16 /Helvetica f ( 2000 .) 1249 1130 w 10 /Times-Roman f (But) 720 1300 w (what) 892 1300 w (if) 1113 1300 w (we) 1201 1300 w (just) 1344 1300 w (want) 1516 1300 w (to) 1737 1300 w (get) 1842 1300 w (out) 1991 1300 w (after) 2146 1300 w (doing) 2355 1300 w 10 /Helvetica f (case) 2613 1300 w (`a') 2855 1300 w 10 /Times-Roman f (?) 2982 1300 w (We) 3078 1300 w (could) 3243 1300 w (get) 3492 1300 w (out) 3641 1300 w (of) 3796 1300 w (a) 3906 1300 w 10 /Helvetica f (case) 3980 1300 w 10 /Times-Roman f (of) 4220 1300 w (the) 4331 1300 w 10 /Helvetica f (switch) 4484 1300 w 10 /Times-Roman f (with) 4790 1300 w (a) 4996 1300 w (label and a) 720 1420 w 10 /Helvetica f (goto,) 1180 1420 w 10 /Times-Roman f (but this is really ugly.) 1429 1420 w (The) 2349 1420 w 10 /Helvetica f (break) 2532 1420 w 10 /Times-Roman f (statement lets us exit without either) 2808 1420 w 10 /Helvetica f (goto) 4255 1420 w 10 /Times-Roman f (or label.) 4476 1420 w 10 /Helvetica f (switch\() 1080 1590 w (c) 1426 1590 w (\)) 1511 1590 w ({) 1579 1590 w (case) 1080 1830 w 10 /S f (\242) 1327 1830 w 10 /Helvetica f (a) 1352 1830 w 10 /S f (\242) 1408 1830 w 10 /Helvetica f (:) 1433 1830 w (aflag) 1440 1950 w 10 /Times-Roman f (++) 1658 1950 w 10 /Helvetica f (;) 1770 1950 w (break;) 1440 2070 w (case) 1080 2190 w 10 /S f (\242) 1327 2190 w 10 /Helvetica f (b) 1352 2190 w 10 /S f (\242) 1408 2190 w 10 /Helvetica f (:) 1433 2190 w (bflag) 1440 2310 w 10 /Times-Roman f (++) 1658 2310 w 10 /Helvetica f (;) 1770 2310 w (break;) 1440 2430 w 16 /Helvetica f (...) 1115 2550 w 10 /Helvetica f (}) 1080 2670 w (/) 1080 2790 w 14 /Helvetica f (*) 1108 2839 w 10 /Helvetica f (the) 1198 2790 w (break) 1373 2790 w (statements) 1659 2790 w (get) 2185 2790 w (us) 2360 2790 w (here) 2501 2790 w (directly) 2737 2790 w 14 /Helvetica f (*) 3089 2839 w 10 /Helvetica f (/) 3144 2790 w 10 /Times-Roman f (The) 720 2960 w 10 /Helvetica f (break) 903 2960 w 10 /Times-Roman f (statement also works in) 1179 2960 w 10 /Helvetica f (for) 2148 2960 w 10 /Times-Roman f (and) 2290 2960 w 10 /Helvetica f (while) 2462 2960 w 10 /Times-Roman f (statements ) 2715 2960 w 10 /S f (_) 3162 2960 w 10 /Times-Roman f (it causes an immediate exit from the loop.) 3237 2960 w (The) 970 3116 w 10 /Helvetica f (continue) 1159 3116 w 10 /Times-Roman f (statement) 1570 3116 w (works) 1984 3116 w 10 /Times-Italic f (only) 2259 3116 w 10 /Times-Roman f (inside) 2462 3116 w 10 /Helvetica f (for's) 2735 3116 w 10 /Times-Roman f (and) 2955 3116 w 10 /Helvetica f (while's;) 3133 3116 w 10 /Times-Roman f (it) 3492 3116 w (causes) 3579 3116 w (the) 3870 3116 w (next) 4024 3116 w (iteration) 4228 3116 w (of) 4593 3116 w (the) 4708 3116 w (loop) 4862 3116 w (to) 720 3236 w (be) 828 3236 w (started.) 952 3236 w (This) 1298 3236 w (means) 1506 3236 w (it) 1791 3236 w (goes) 1877 3236 w (to) 2090 3236 w (the) 2198 3236 w (increment) 2350 3236 w (part) 2779 3236 w (of) 2964 3236 w (the) 3077 3236 w 10 /Helvetica f (for) 3232 3236 w 10 /Times-Roman f (and) 3379 3236 w (the) 3553 3236 w (test) 3705 3236 w (part) 3874 3236 w (of) 4058 3236 w (the) 4170 3236 w 10 /Helvetica f (while) 4324 3236 w 16 /Helvetica f (.) 4552 3236 w 10 /Times-Roman f (We) 4651 3236 w (could) 4818 3236 w (have) 720 3356 w (used) 935 3356 w (a) 1145 3356 w 10 /Helvetica f (continue) 1219 3356 w 10 /Times-Roman f (in) 1626 3356 w (our) 1731 3356 w (example) 1891 3356 w (to) 2256 3356 w (get) 2361 3356 w (on) 2510 3356 w (with) 2637 3356 w (the) 2843 3356 w (next) 2993 3356 w (iteration) 3193 3356 w (of) 3554 3356 w (the) 3665 3356 w 10 /Helvetica f (for,) 3818 3356 w 10 /Times-Roman f (but) 3991 3356 w (it) 4147 3356 w (seems) 4231 3356 w (clearer) 4503 3356 w (to) 4801 3356 w (use) 4907 3356 w 10 /Helvetica f (break) 720 3476 w 10 /Times-Roman f (instead.) 996 3476 w 10 /Helvetica f (20. Structures) 720 3716 w 10 /Times-Roman f (The) 970 3872 w (main) 1162 3872 w (use) 1399 3872 w (of) 1569 3872 w (structures) 1689 3872 w (is) 2114 3872 w (to) 2218 3872 w (lump) 2333 3872 w (together) 2577 3872 w (collections) 2942 3872 w (of) 3413 3872 w (disparate) 3534 3872 w (variable) 3932 3872 w (types,) 4291 3872 w (so) 4565 3872 w (they) 4692 3872 w (can) 4902 3872 w (conveniently) 720 3992 w (be) 1264 3992 w (treated) 1386 3992 w (as) 1685 3992 w (a) 1796 3992 w (unit.) 1868 3992 w (For) 2102 3992 w (example,) 2269 3992 w (if) 2660 3992 w (we) 2749 3992 w (were) 2893 3992 w (writing) 3114 3992 w (a) 3431 3992 w (compiler) 3503 3992 w (or) 3886 3992 w (assembler,) 3997 3992 w (we) 4448 3992 w (might) 4591 3992 w (need) 4852 3992 w (for) 720 4112 w (each) 869 4112 w (identifier) 1084 4112 w (information) 1483 4112 w (like) 1988 4112 w (its) 2171 4112 w (name) 2299 4112 w (\(a) 2548 4112 w (character) 2659 4112 w (array\),) 3057 4112 w (its) 3353 4112 w (source) 3482 4112 w (line) 3776 4112 w (number) 3960 4112 w (\(an) 4299 4112 w (integer\),) 4460 4112 w (some) 4829 4112 w (type information \(a character, perhaps\), and probably a usage count \(another integer\).) 720 4232 w 10 /Helvetica f (char) 1440 4402 w (id[10];) 1800 4402 w (int) 1440 4522 w (line;) 1800 4522 w (char) 1440 4642 w (type;) 1800 4642 w (int) 1440 4762 w (usage;) 1800 4762 w 10 /Times-Roman f (We) 970 4968 w (can) 1134 4968 w (make) 1298 4968 w (a) 1540 4968 w (structure) 1610 4968 w (out) 1985 4968 w (of) 2139 4968 w (this) 2248 4968 w (quite) 2419 4968 w (easily.) 2645 4968 w (We) 2954 4968 w (first) 3118 4968 w (tell) 3305 4968 w (C) 3460 4968 w (what) 3554 4968 w (the) 3775 4968 w (structure) 3924 4968 w (will) 4300 4968 w (look) 4483 4968 w (like,) 4688 4968 w (that) 4890 4968 w (is,) 720 5088 w (what) 840 5088 w (kinds) 1062 5088 w (of) 1307 5088 w (things) 1418 5088 w (it) 1691 5088 w (contains;) 1775 5088 w (after) 2164 5088 w (that) 2374 5088 w (we) 2552 5088 w (can) 2696 5088 w (actually) 2861 5088 w (reserve) 3204 5088 w (storage) 3518 5088 w (for) 3833 5088 w (it,) 3976 5088 w (either) 4084 5088 w (in) 4338 5088 w (the) 4443 5088 w (same) 4592 5088 w (state\255) 4824 5088 w (ment or separately.) 720 5208 w (The simplest thing is to define it and allocate storage all at once:) 1532 5208 w 10 /Helvetica f (struct) 1080 5378 w ({) 1360 5378 w (char) 1440 5498 w (id[10];) 1800 5498 w (int) 1440 5618 w (line;) 1800 5618 w (char) 1440 5738 w (type;) 1800 5738 w (int) 1440 5858 w (usage;) 1800 5858 w (}) 1080 5978 w (sym;) 1148 5978 w 10 /Times-Roman f (This defines) 970 6184 w 10 /Helvetica f (sym) 1489 6184 w 10 /Times-Roman f (to be) 1697 6184 w (a) 1920 6184 w (structure) 1990 6184 w (with) 2365 6184 w (the) 2569 6184 w (specified) 2717 6184 w (shape;) 3103 6184 w 10 /Helvetica f (id,) 3387 6184 w (line,) 3522 6184 w (type) 3735 6184 w 10 /Times-Roman f (and) 3951 6184 w 10 /Helvetica f (usage) 4124 6184 w 10 /Times-Roman f (are) 4424 6184 w 10 /Times-Italic f (members) 4571 6184 w 10 /Times-Roman f (of) 4957 6184 w (the structure.) 720 6304 w (The way we refer to any particular member of the structure is) 1291 6304 w 10 /Helvetica f (structure\255name) 1080 6474 w 16 /Helvetica f (.) 1789 6474 w 10 /Helvetica f (member) 1869 6474 w 10 /Times-Roman f (as in) 720 6644 w 10 /Helvetica f (sym) 1440 6814 w 16 /Helvetica f (.) 1623 6814 w 10 /Helvetica f (type) 1668 6814 w (=) 1893 6814 w (077;) 1986 6814 w (if\() 1440 6934 w (sym) 1558 6934 w 16 /Helvetica f (.) 1741 6934 w 10 /Helvetica f (usage) 1786 6934 w 10 /Times-Roman f (==) 2095 6934 w 10 /Helvetica f (0) 2242 6934 w (\)) 2333 6934 w 16 /Helvetica f (...) 2401 6934 w 10 /Helvetica f (while\() 1440 7054 w (sym) 1736 7054 w 16 /Helvetica f (.) 1919 7054 w 10 /Helvetica f (id[j) 1964 7054 w 10 /Times-Roman f (++) 2092 7054 w 10 /Helvetica f (]) 2204 7054 w (\)) 2267 7054 w 16 /Helvetica f (...) 2335 7054 w 10 /Times-Roman f (etc) 1533 7174 w 16 /Times-Roman f (.) 1649 717 2000 4 w cleartomark showpage saveobj restore %%EndPage: 16 16 %%Page: 17 17 /saveobj save def mark 17 pagesetup 10 /Times-Roman f (C ) 720 360 w (Tutorial) 818 360 w (\255 ) 2946 360 w (17 ) 3010 360 w (\255) 3141 360 w (Although) 720 840 w (the) 1131 840 w (names) 1286 840 w (of) 1574 840 w (structure) 1690 840 w (members) 2072 840 w (never) 2471 840 w (stand) 2725 840 w (alone,) 2969 840 w (they) 3243 840 w (still) 3448 840 w (have) 3632 840 w (to) 3853 840 w (be) 3964 840 w (unique) 4091 840 w 10 /S f (_) 4396 840 w 10 /Times-Roman f (there) 4480 840 w (can't) 4713 840 w (be) 4946 840 w (another) 720 960 w 10 /Helvetica f (id) 1047 960 w 10 /Times-Roman f (or) 1150 960 w 10 /Helvetica f (usage) 1261 960 w 10 /Times-Roman f (in some other structure.) 1560 960 w (So) 970 1116 w (far) 1106 1116 w (we) 1246 1116 w (haven't) 1392 1116 w (gained) 1721 1116 w (much.) 2017 1116 w (The) 2319 1116 w (advantages) 2504 1116 w (of) 2978 1116 w (structures) 3092 1116 w (start) 3511 1116 w (to) 3714 1116 w (come) 3823 1116 w (when) 4070 1116 w (we) 4317 1116 w (have) 4464 1116 w (arrays) 4683 1116 w (of) 4957 1116 w (structures,) 720 1236 w (or) 1169 1236 w (when) 1288 1236 w (we) 1540 1236 w (want) 1692 1236 w (to) 1922 1236 w (pass) 2035 1236 w (complicated) 2242 1236 w (data) 2765 1236 w (layouts) 2966 1236 w (between) 3290 1236 w (functions.) 3657 1236 w (Suppose) 4114 1236 w (we) 4488 1236 w (wanted) 4639 1236 w (to) 4962 1236 w (make a symbol table for up to 100 identifiers.) 720 1356 w (We could extend our definitions like) 2593 1356 w 10 /Helvetica f (char) 1440 1526 w (id[100][10];) 1800 1526 w (int) 1440 1646 w (line[100];) 1800 1646 w (char) 1440 1766 w (type[100];) 1800 1766 w (int) 1440 1886 w (usage[100];) 1800 1886 w 10 /Times-Roman f (but) 720 2056 w (a) 882 2056 w (structure) 960 2056 w (lets) 1343 2056 w (us) 1516 2056 w (rearrange) 1639 2056 w (this) 2048 2056 w (spread\255out) 2227 2056 w (information) 2682 2056 w (so) 3188 2056 w (all) 3311 2056 w (the) 3445 2056 w (data) 3601 2056 w (about) 3801 2056 w (a) 4057 2056 w (single) 4136 2056 w (identifer) 4410 2056 w (is) 4783 2056 w (col\255) 4885 2056 w (lected into one lump:) 720 2176 w 10 /Helvetica f (struct) 1080 2346 w ({) 1360 2346 w (char) 1440 2466 w (id[10];) 1800 2466 w (int) 1440 2586 w (line;) 1800 2586 w (char) 1440 2706 w (type;) 1800 2706 w (int) 1440 2826 w (usage;) 1800 2826 w (}) 1080 2946 w (sym[100];) 1148 2946 w 10 /Times-Roman f (This) 720 3116 w (makes) 931 3116 w 10 /Helvetica f (sym) 1222 3116 w 10 /Times-Roman f (an) 1438 3116 w (array) 1565 3116 w (of) 1802 3116 w (structures;) 1918 3116 w (each) 2367 3116 w (array) 2582 3116 w (element) 2819 3116 w (has) 3168 3116 w (the) 3334 3116 w (specified) 3489 3116 w (shape.) 3882 3116 w (Now) 4192 3116 w (we) 4419 3116 w (can) 4569 3116 w (refer) 4741 3116 w (to) 4962 3116 w (members as) 720 3236 w 10 /Helvetica f (sym[i]) 1440 3406 w 16 /Helvetica f (.) 1701 3406 w 10 /Helvetica f (usage) 1746 3406 w 10 /Times-Roman f (++) 2020 3406 w 10 /Helvetica f (;) 2132 3406 w (/) 2520 3406 w 14 /Helvetica f (*) 2548 3455 w 10 /Helvetica f (increment) 2638 3406 w (usage) 3113 3406 w (of) 3422 3406 w (i\255th) 3541 3406 w (identifier) 3715 3406 w 14 /Helvetica f (*) 4129 3455 w 10 /Helvetica f (/) 4184 3406 w (for\() 1440 3526 w (j=0;) 1625 3526 w (sym[i]) 1824 3526 w 16 /Helvetica f (.) 2085 3526 w 10 /Helvetica f (id[j) 2130 3526 w 10 /Times-Roman f (++) 2258 3526 w 10 /Helvetica f (]) 2370 3526 w (!=) 2433 3526 w 10 /S f (\242) 2554 3526 w 10 /Helvetica f (\\0) 2579 3526 w 10 /S f (\242) 2663 3526 w 10 /Helvetica f (;) 2688 3526 w (\)) 2751 3526 w 16 /Helvetica f (...) 2819 3526 w 10 /Times-Roman f (etc) 1533 3646 w 16 /Times-Roman f (.) 1649 3646 w 10 /Times-Roman f (Thus to print a list of all identifiers that haven't been used, together with their line number,) 720 3816 w 10 /Helvetica f (for\() 1440 3986 w (i=0;) 1625 3986 w (i=) 2824 6022 w (0) 2975 6022 w (\)) 3066 6022 w (sym[index]) 1800 6142 w 16 /Helvetica f (.) 2279 6142 w 10 /Helvetica f (usage) 2324 6142 w 10 /Times-Roman f (++) 2598 6142 w 10 /Helvetica f (;) 2710 6142 w (/) 3240 6142 w 14 /Helvetica f (*) 3268 6191 w 10 /Helvetica f (already) 3358 6142 w (there) 3722 6142 w 16 /Helvetica f (...) 3986 6142 w 14 /Helvetica f (*) 4156 6191 w 10 /Helvetica f (/) 4211 6142 w (else) 1440 6262 w (install\(newname,) 1800 6382 w (newline,) 2587 6382 w (newtype\);) 2990 6382 w 16 /Helvetica f (...) 1440 6502 w 10 /Helvetica f (}) 1080 6622 w (lookup\(s\)) 1080 6792 w (char) 1185 6912 w 14 /Helvetica f (*) 1415 6961 w 10 /Helvetica f (s;) 1470 6912 w ({) 1583 6912 w (int) 1440 7032 w (i;) 1581 7032 w (extern) 1440 7152 w (struct) 1754 7152 w ({) 2034 7152 w (char) 1800 7272 w (id[10];) 2160 7272 w cleartomark showpage saveobj restore %%EndPage: 17 17 %%Page: 18 18 /saveobj save def mark 18 pagesetup 10 /Helvetica f (C ) 720 360 w (Tutorial) 827 360 w 10 /S f (-) 2914 360 w 10 /Helvetica f (18 ) 3004 360 w 10 /S f (-) 3151 360 w 10 /Helvetica f (int) 1800 840 w (line;) 2160 840 w (char) 1800 960 w (type;) 2160 960 w (int) 1800 1080 w (usage;) 2160 1080 w (}) 1440 1200 w (sym[) 1508 1200 w (];) 1754 1200 w (for\() 1440 1370 w (i=0;) 1625 1370 w (i) 2850 1490 w (0) 2943 1490 w (\)) 3034 1490 w (return\(i\);) 2160 1610 w (return\() 1440 1730 w 10 /S f (-) 1735 1730 w 10 /Helvetica f (1\);) 1790 1730 w (}) 1080 1850 w (compar\(s1,s2\)) 1080 2090 w (/) 2160 2090 w 14 /Helvetica f (*) 2188 2139 w 10 /Helvetica f (return) 2313 2090 w (1) 2610 2090 w (if) 2701 2090 w (s1) 2786 2090 w 10 /Times-Roman f (==) 2892 2090 w 10 /Helvetica f (s2,) 3004 2090 w (0) 3173 2090 w (otherwise) 3264 2090 w 14 /Helvetica f (*) 3728 2139 w 10 /Helvetica f (/) 3783 2090 w (char) 1185 2210 w 14 /Helvetica f (*) 1415 2259 w 10 /Helvetica f (s1,) 1470 2210 w 14 /Helvetica f (*) 1639 2259 w 10 /Helvetica f (s2;) 1694 2210 w ({) 1863 2210 w (while\() 1440 2330 w 14 /Helvetica f (*) 1736 2379 w 10 /Helvetica f (s1) 1791 2330 w 10 /Times-Roman f (++) 1897 2330 w (==) 2044 2330 w 14 /Helvetica f (*) 2191 2379 w 10 /Helvetica f (s2) 2246 2330 w (\)) 2387 2330 w (if\() 1800 2450 w 14 /Helvetica f (*) 1918 2499 w 10 /Helvetica f (s2) 1973 2450 w 10 /Times-Roman f (++) 2079 2450 w (==) 2226 2450 w 10 /S f (\242) 2373 2450 w 10 /Helvetica f (\\0) 2398 2450 w 10 /S f (\242) 2482 2450 w 10 /Helvetica f (\)) 2542 2450 w (return\(1\);) 2160 2570 w (return\(0\);) 1440 2690 w (}) 1080 2810 w 10 /Times-Roman f (The declaration of the structure in) 720 2980 w 10 /Helvetica f (lookup) 2103 2980 w 10 /Times-Roman f (isn't needed if the external) 2424 2980 w (definition) 3514 2980 w (precedes) 3929 2980 w (its) 4303 2980 w (use) 4424 2980 w (in) 4583 2980 w (the) 4687 2980 w (same) 4835 2980 w (source file, as we shall see in a moment.) 720 3100 w (Now what if we want to use pointers?) 970 3256 w 10 /Helvetica f (struct) 1080 3426 w (symtag) 1395 3426 w ({) 1753 3426 w (char) 1440 3546 w (id[10];) 1800 3546 w (int) 1440 3666 w (line;) 1800 3666 w (char) 1440 3786 w (type;) 1800 3786 w (int) 1440 3906 w (usage;) 1800 3906 w (}) 1080 4026 w (sym[100],) 1148 4026 w 14 /Helvetica f (*) 1618 4075 w 10 /Helvetica f (psym;) 1673 4026 w (psym) 1440 4266 w (=) 1714 4266 w (&sym[0];) 1807 4266 w (/) 2520 4266 w 14 /Helvetica f (*) 2548 4315 w 10 /Helvetica f (or) 2638 4266 w (p) 2762 4266 w (=) 2853 4266 w (sym;) 2946 4266 w 14 /Helvetica f (*) 3192 4315 w 10 /Helvetica f (/) 3247 4266 w 10 /Times-Roman f (This) 720 4436 w (makes) 924 4436 w 10 /Helvetica f (psym) 1208 4436 w 10 /Times-Roman f (a) 1473 4436 w (pointer) 1543 4436 w (to) 1852 4436 w (our) 1956 4436 w (kind) 2115 4436 w (of) 2320 4436 w (structure) 2430 4436 w (\(the) 2806 4436 w (symbol) 2988 4436 w (table\),) 3310 4436 w (then) 3589 4436 w (initializes) 3788 4436 w (it) 4204 4436 w (to) 4287 4436 w (point) 4392 4436 w (to) 4625 4436 w (the) 4730 4436 w (first) 4879 4436 w (element of) 720 4556 w 10 /Helvetica f (sym) 1172 4556 w 16 /Helvetica f (.) 1355 4556 w 10 /Times-Roman f (Notice) 970 4712 w (that) 1263 4712 w (we) 1440 4712 w (added) 1583 4712 w (something) 1848 4712 w (after) 2292 4712 w (the) 2501 4712 w (word) 2650 4712 w 10 /Helvetica f (struct:) 2885 4712 w 10 /Times-Roman f (a) 3185 4712 w (``tag'') 3256 4712 w (called) 3537 4712 w 10 /Helvetica f (symtag) 3805 4712 w 16 /Helvetica f (.) 4128 4712 w 10 /Times-Roman f (This) 4225 4712 w (puts) 4430 4712 w (a) 4624 4712 w (name) 4696 4712 w (on) 4940 4712 w (our) 720 4832 w (structure) 888 4832 w (definition) 1272 4832 w (so) 1696 4832 w (we) 1820 4832 w (can) 1971 4832 w (refer) 2144 4832 w (to) 2366 4832 w (it) 2479 4832 w (later) 2570 4832 w (without) 2782 4832 w (repeating) 3123 4832 w (the) 3529 4832 w (definition.) 3686 4832 w (It's) 4160 4832 w (not) 4328 4832 w (necessary) 4491 4832 w (but) 4912 4832 w (useful.) 720 4952 w (In fact we could have said) 1039 4952 w 10 /Helvetica f (struct) 1080 5122 w (symtag) 1440 5122 w ({) 1798 5122 w 16 /Helvetica f (...) 1440 5242 w 10 /Helvetica f (structure) 1610 5242 w (definition) 2035 5242 w (};) 1080 5362 w 10 /Times-Roman f (which wouldn't have assigned any storage at all, and then said) 720 5532 w 10 /Helvetica f (struct) 1080 5702 w (symtag) 1440 5702 w (sym[100];) 1800 5702 w (struct) 1080 5822 w (symtag) 1440 5822 w 14 /Helvetica f (*) 1800 5871 w 10 /Helvetica f (psym;) 1855 5822 w 10 /Times-Roman f (which would define the array and the pointer.) 720 5992 w (This could be condensed further, to) 2588 5992 w 10 /Helvetica f (struct) 1080 6162 w (symtag) 1440 6162 w (sym[100],) 1800 6162 w 14 /Helvetica f (*) 2270 6211 w 10 /Helvetica f (psym;) 2325 6162 w 10 /Times-Roman f (The way we actually refer to an member of a structure by a pointer is like this:) 970 6368 w 10 /Helvetica f (ptr) 1440 6538 w 10 /S f (-) 1592 6538 w 10 /Helvetica f (>) 1647 6538 w (structure\255member) 1740 6538 w 10 /Times-Roman f (The) 720 6708 w (symbol) 903 6708 w (`) 1226 6708 w 10 /S f (-) 1259 6708 w 10 /Times-Roman f (>') 1314 6708 w (means) 1431 6708 w (we're) 1714 6708 w (pointing) 1968 6708 w (at) 2330 6708 w (a) 2430 6708 w (member) 2502 6708 w (of) 2857 6708 w (a) 2968 6708 w (structure;) 3040 6708 w (`) 3445 6708 w 10 /S f (-) 3478 6708 w 10 /Times-Roman f (>') 3533 6708 w (is) 3650 6708 w (only) 3745 6708 w (used) 3951 6708 w (in) 4162 6708 w (that) 4269 6708 w (context.) 4448 6708 w 10 /Helvetica f (ptr) 4827 6708 w 10 /Times-Roman f (is) 4973 6708 w (a) 720 6828 w (pointer) 847 6828 w (to) 1213 6828 w (the) 1374 6828 w (\(base) 1579 6828 w (of\)) 1872 6828 w (a) 2071 6828 w (structure) 2198 6828 w (that) 2630 6828 w (contains) 2863 6828 w (the) 3279 6828 w (structure) 3484 6828 w (member.) 3916 6828 w (The) 4376 6828 w (expression) 4613 6828 w 10 /Helvetica f (ptr) 720 6948 w 10 /S f (-) 837 6948 w 10 /Helvetica f (>structure\255member) 892 6948 w 10 /Times-Roman f (refers) 1777 6948 w (to) 2040 6948 w (the) 2155 6948 w (indicated) 2314 6948 w (member) 2717 6948 w (of) 3081 6948 w (the) 3201 6948 w (pointed\255to) 3360 6948 w (structure.) 3808 6948 w (Thus) 4245 6948 w (we) 4483 6948 w (have) 4637 6948 w (con\255) 4863 6948 w (structions like:) 720 7068 w 10 /Helvetica f (psym) 1080 7238 w 10 /S f (-) 1319 7238 w 10 /Helvetica f (>type) 1374 7238 w (=) 1657 7238 w (1;) 1750 7238 w cleartomark showpage saveobj restore %%EndPage: 18 18 %%Page: 19 19 /saveobj save def mark 19 pagesetup 10 /Helvetica f (C ) 720 360 w (Tutorial) 827 360 w 10 /S f (-) 2914 360 w 10 /Helvetica f (19 ) 3004 360 w 10 /S f (-) 3151 360 w 10 /Helvetica f (psym) 1080 840 w 10 /S f (-) 1319 840 w 10 /Helvetica f (>id[0]) 1374 840 w (=) 1657 840 w 10 /S f (\242) 1750 840 w 10 /Helvetica f (a) 1775 840 w 10 /S f (\242) 1831 840 w 10 /Helvetica f (;) 1856 840 w 10 /Times-Roman f (and so on.) 720 1010 w (For more complicated pointer expressions, it's wise to use parentheses to make it clear who goes) 970 1166 w (with) 4862 1166 w (what.) 720 1286 w (For example,) 989 1286 w 10 /Helvetica f (struct) 1080 1456 w ({) 1360 1456 w (int) 1428 1456 w (x,) 1569 1456 w 14 /Helvetica f (*) 1682 1505 w 10 /Helvetica f (y;) 1737 1456 w (}) 1850 1456 w 14 /Helvetica f (*) 1918 1505 w 10 /Helvetica f (p;) 1973 1456 w (p) 1080 1576 w 10 /S f (-) 1136 1576 w 10 /Helvetica f (>x) 1191 1576 w 10 /Times-Roman f (++) 1299 1576 w 10 /Helvetica f (increments) 1440 1576 w (x) 1965 1576 w 10 /Times-Roman f (++) 1080 1696 w 10 /Helvetica f (p) 1192 1696 w 10 /S f (-) 1248 1696 w 10 /Helvetica f (>x) 1303 1696 w (so) 1440 1696 w (does) 1581 1696 w (this!) 1834 1696 w (\() 1080 1816 w 10 /Times-Roman f (++) 1113 1816 w 10 /Helvetica f (p\)) 1225 1816 w 10 /S f (-) 1314 1816 w 10 /Helvetica f (>x) 1369 1816 w (increments) 1800 1816 w (p) 2325 1816 w (before) 2416 1816 w (getting) 2736 1816 w (x) 3073 1816 w 14 /Helvetica f (*) 1080 1985 2000 w 10 /Helvetica f (p) 1135 1936 w 10 /S f (-) 1191 1936 w 10 /Helvetica f (>y) 1246 1936 w 10 /Times-Roman f (++) 1354 1936 w 10 /Helvetica f (uses) 1800 1936 w (y) 2047 1936 w (as) 2132 1936 w (a) 2273 1936 w (pointer,) 2364 1936 w (then) 2734 1936 w (increments) 2965 1936 w (it) 3490 1936 w 14 /Helvetica f (*) 1080 2105 w 10 /Helvetica f (\(p) 1135 2056 w 10 /S f (-) 1224 2056 w 10 /Helvetica f (>y\)) 1279 2056 w 10 /Times-Roman f (++) 1420 2056 w 10 /Helvetica f (so) 1800 2056 w (does) 1941 2056 w (this) 2194 2056 w 14 /Helvetica f (*) 1080 2225 w 10 /Helvetica f (\(p) 1135 2176 w 10 /Times-Roman f (++) 1224 2176 w 10 /Helvetica f (\)) 1336 2176 w 10 /S f (-) 1369 2176 w 10 /Helvetica f (>y) 1424 2176 w (uses) 1800 2176 w (y) 2047 2176 w (as) 2132 2176 w (a) 2273 2176 w (pointer,) 2364 2176 w (then) 2734 2176 w (increments) 2965 2176 w (p) 3490 2176 w 10 /Times-Roman f (The) 720 2346 w (way) 902 2346 w (to) 1095 2346 w (remember) 1200 2346 w (these) 1631 2346 w (is) 1863 2346 w (that) 1957 2346 w 10 /S f (-) 2137 2346 w 10 /Helvetica f (>,) 2192 2346 w (.) 2308 2346 w 10 /Times-Roman f (\(dot\),) 2363 2346 w 10 /Helvetica f (\() 2612 2346 w (\)) 2675 2346 w 10 /Times-Roman f (and) 2735 2346 w 10 /Helvetica f ([) 2909 2346 w (]) 2967 2346 w 10 /Times-Roman f (bind) 3022 2346 w (very) 3227 2346 w (tightly.) 3431 2346 w (An) 3770 2346 w (expression) 3919 2346 w (involving) 4373 2346 w (one) 4785 2346 w (of) 4957 2346 w (these is treated as a unit.) 720 2466 w 10 /Helvetica f (p) 1752 2466 w 10 /S f (-) 1808 2466 w 10 /Helvetica f (>x, a[i], y) 1863 2466 w 16 /Helvetica f (.) 2267 2466 w 10 /Helvetica f (x) 2312 2466 w 10 /Times-Roman f (and) 2387 2466 w 10 /Helvetica f (f\(b\)) 2559 2466 w 10 /Times-Roman f (are names exactly as) 2734 2466 w 10 /Helvetica f (abc) 3584 2466 w 10 /Times-Roman f (is.) 3771 2466 w (If) 970 2622 w 10 /Helvetica f (p) 1068 2622 w 10 /Times-Roman f (is) 1153 2622 w (a) 1249 2622 w (pointer) 1322 2622 w (to) 1634 2622 w (a) 1741 2622 w (structure,) 1814 2622 w (any) 2217 2622 w (arithmetic) 2390 2622 w (on) 2824 2622 w 10 /Helvetica f (p) 2956 2622 w 10 /Times-Roman f (takes) 3041 2622 w (into) 3275 2622 w (account) 3460 2622 w (the) 3799 2622 w (acutal) 3950 2622 w (size) 4217 2622 w (of) 4401 2622 w (the) 4514 2622 w (structure.) 4666 2622 w (For) 720 2742 w (instance,) 885 2742 w 10 /Helvetica f (p) 1266 2742 w 10 /Times-Roman f (++) 1322 2742 w (increments) 1460 2742 w 10 /Helvetica f (p) 1926 2742 w 10 /Times-Roman f (by the correct amount to get the next element of the array of structures.) 2007 2742 w (But) 4895 2742 w (don't) 720 2862 w (assume) 961 2862 w (that) 1285 2862 w (the) 1465 2862 w (size) 1617 2862 w (of) 1802 2862 w (a) 1915 2862 w (structure) 1989 2862 w (is) 2368 2862 w (the) 2466 2862 w (sum) 2619 2862 w (of) 2817 2862 w (the) 2931 2862 w (sizes) 3084 2862 w (of) 3309 2862 w (its) 3423 2862 w (members) 3549 2862 w 10 /S f (_) 3946 2862 w 10 /Times-Roman f (because) 4027 2862 w (of) 4373 2862 w (alignments) 4487 2862 w (of) 4957 2862 w (different sized objects, there may be ``holes'' in a structure.) 720 2982 w (Enough theory. Here is the lookup example, this time with pointers.) 970 3138 w 10 /Helvetica f (struct) 1080 3308 w (symtag) 1360 3308 w ({) 1718 3308 w (char) 1440 3428 w (id[10];) 1800 3428 w (int) 1440 3548 w (line;) 1800 3548 w (char) 1440 3668 w (type;) 1800 3668 w (int) 1440 3788 w (usage;) 1800 3788 w (}) 1080 3908 w (sym[100];) 1148 3908 w (main\() 1080 4078 w (\)) 1365 4078 w ({) 1433 4078 w (struct) 1440 4198 w (symtag) 1720 4198 w 14 /Helvetica f (*) 2078 4247 w 10 /Helvetica f (lookup\() 2133 4198 w (\);) 2497 4198 w (struct) 1440 4318 w (symtag) 1720 4318 w 14 /Helvetica f (*) 2078 4367 w 10 /Helvetica f (psym;) 2133 4318 w 16 /Helvetica f (...) 1440 4438 w 10 /Helvetica f (if\() 1440 4558 w (\(psym) 1558 4558 w (=) 1865 4558 w (lookup\(newname\)\)) 1958 4558 w (\)) 2823 4558 w (/) 2880 4558 w 14 /Helvetica f (*) 2908 4607 w 10 /Helvetica f (non) 2998 4558 w 10 /S f (-) 3166 4558 w 10 /Helvetica f (zero) 3221 4558 w (pointer) 3451 4558 w 14 /Helvetica f (*) 3793 4607 w 10 /Helvetica f (/) 3848 4558 w (psym) 1800 4678 w 10 /S f (-) 2074 4678 w 10 /Helvetica f (>) 2129 4678 w (usage) 2222 4678 w 10 /Times-Roman f (++) 2496 4678 w 10 /Helvetica f (;) 2608 4678 w (/) 3240 4678 w 14 /Helvetica f (*) 3268 4727 w 10 /Helvetica f (means) 3358 4678 w (already) 3694 4678 w (there) 4058 4678 w 14 /Helvetica f (*) 4322 4727 w 10 /Helvetica f (/) 4377 4678 w (else) 1440 4798 w (install\(newname,) 1800 4918 w (newline,) 2587 4918 w (newtype\);) 2990 4918 w 16 /Helvetica f (...) 1440 5038 w 10 /Helvetica f (}) 1080 5158 w (struct) 1080 5328 w (symtag) 1360 5328 w 14 /Helvetica f (*) 1718 5377 w 10 /Helvetica f (lookup\(s\)) 1773 5328 w (char) 1185 5448 w 14 /Helvetica f (*) 1415 5497 w 10 /Helvetica f (s;) 1470 5448 w ({) 1583 5448 w (struct) 1440 5568 w (symtag) 1720 5568 w 14 /Helvetica f (*) 2078 5617 w 10 /Helvetica f (p;) 2133 5568 w (for\() 1440 5688 w (p=sym;) 1625 5688 w (p) 1985 5688 w (<) 2076 5688 w (&sym[nsym];) 2169 5688 w (p) 2777 5688 w 10 /Times-Roman f (++) 2833 5688 w 10 /Helvetica f (\)) 2980 5688 w (if\() 1800 5808 w (compar\(s,) 1918 5808 w (p) 2398 5808 w 10 /S f (-) 2454 5808 w 10 /Helvetica f (>id\)) 2509 5808 w (>) 2713 5808 w (0\)) 2806 5808 w (return\(p\);) 2160 5928 w (return\(0\);) 1440 6048 w (}) 1080 6168 w 10 /Times-Roman f (The function) 720 6338 w 10 /Helvetica f (compar) 1261 6338 w 10 /Times-Roman f (doesn't change:) 1620 6338 w 10 /Helvetica f (`p) 2277 6338 w 10 /S f (-) 2355 6338 w 10 /Helvetica f (>id') 2410 6338 w 10 /Times-Roman f (refers to a string.) 2593 6338 w (In) 970 6494 w 10 /Helvetica f (main) 1087 6494 w 10 /Times-Roman f (we) 1335 6494 w (test) 1482 6494 w (the) 1652 6494 w (pointer) 1805 6494 w (returned) 2119 6494 w (by) 2482 6494 w 10 /Helvetica f (lookup) 2616 6494 w 10 /Times-Roman f (against) 2943 6494 w (zero,) 3258 6494 w (relying) 3486 6494 w (on) 3801 6494 w (the) 3933 6494 w (fact) 4087 6494 w (that) 4268 6494 w (a) 4450 6494 w (pointer) 4526 6494 w (is) 4841 6494 w (by) 4940 6494 w (definition never zero when it really points at something.) 720 6614 w (The other pointer manipulations are trivial.) 3009 6614 w (The only complexity is the set of lines like) 970 6770 w 10 /Helvetica f (struct) 1080 6940 w (symtag) 1360 6940 w 14 /Helvetica f (*) 1718 6989 w 10 /Helvetica f (lookup\() 1773 6940 w (\);) 2137 6940 w 10 /Times-Roman f (This) 720 7110 w (brings) 924 7110 w (us) 1200 7110 w (to) 1315 7110 w (an) 1419 7110 w (area) 1539 7110 w (that) 1730 7110 w (we) 1906 7110 w (will) 2048 7110 w (treat) 2230 7110 w (only) 2433 7110 w (hurriedly) 2637 7110 w 10 /S f (_) 3029 7110 w 10 /Times-Roman f (the) 3105 7110 w (question) 3253 7110 w (of) 3618 7110 w (function) 3727 7110 w (types.) 4087 7110 w (So) 4375 7110 w (far,) 4508 7110 w (all) 4670 7110 w (of) 4797 7110 w (our) 4907 7110 w (functions) 720 7230 w (have) 1121 7230 w (returned) 1338 7230 w (integers) 1699 7230 w (\(or) 2044 7230 w (characters,) 2189 7230 w (which) 2646 7230 w (are) 2919 7230 w (much) 3069 7230 w (the) 3320 7230 w (same\).) 3471 7230 w (What) 3788 7230 w (do) 4033 7230 w (we) 4162 7230 w (do) 4307 7230 w (when) 4436 7230 w (the) 4680 7230 w (func\255) 4830 7230 w cleartomark showpage saveobj restore %%EndPage: 19 19 %%Page: 20 20 /saveobj save def mark 20 pagesetup 10 /Times-Roman f (C Tutorial) 720 360 w (\255 20 \255) 2952 360 w (tion returns) 720 840 w (something) 1204 840 w (else,) 1647 840 w (like) 1853 840 w (a) 2029 840 w (pointer) 2099 840 w (to) 2408 840 w (a) 2512 840 w (structure?) 2582 840 w (The) 3026 840 w (rule) 3207 840 w (is) 3388 840 w (that) 3481 840 w (any) 3657 840 w (function) 3827 840 w (that) 4186 840 w (doesn't) 4362 840 w ( 2000 return) 4682 840 w (an) 4946 840 w 10 /Helvetica f (int) 720 960 w 10 /Times-Roman f (has) 861 960 w (to) 1029 960 w (say) 1142 960 w (explicitly) 1310 960 w (what) 1723 960 w (it) 1952 960 w (does) 2043 960 w (return.) 2261 960 w (The) 2584 960 w (type) 2773 960 w (information) 2979 960 w (goes) 3485 960 w (before) 3702 960 w (the) 3990 960 w (function) 4146 960 w (name) 4513 960 w (\(which) 4763 960 w (can make the name hard to see\).) 720 1080 w (Examples:) 2052 1080 w 10 /Helvetica f (char) 1080 1250 w (f\(a\)) 1310 1250 w (int) 1185 1370 w (a;) 1326 1370 w ({) 1445 1370 w 16 /Helvetica f (...) 1440 1490 w 10 /Helvetica f (}) 1080 1610 w (int) 1080 1850 w 14 /Helvetica f (*) 1221 1899 w 10 /Helvetica f (g\() 1276 1850 w (\)) 1400 1850 w ({) 1468 1850 w 16 /Helvetica f (...) 1536 1850 w 10 /Helvetica f (}) 1706 1850 w (struct) 1080 2090 w (symtag) 1360 2090 w 14 /Helvetica f (*) 1718 2139 w 10 /Helvetica f (lookup\(s\)) 1773 2090 w (char) 2220 2090 w 14 /Helvetica f (*) 2450 2139 w 10 /Helvetica f (s;) 2505 2090 w ({) 2618 2090 w 16 /Helvetica f (...) 2686 2090 w 10 /Helvetica f (}) 2856 2090 w 10 /Times-Roman f (The) 720 2260 w (function) 902 2260 w 10 /Helvetica f (f) 1265 2260 w 10 /Times-Roman f (returns) 1321 2260 w (a) 1626 2260 w (character,) 1698 2260 w 10 /Helvetica f (g) 2118 2260 w 10 /Times-Roman f (returns) 2202 2260 w (a) 2507 2260 w (pointer) 2579 2260 w (to) 2890 2260 w (an) 2996 2260 w (integer,) 3118 2260 w (and) 3448 2260 w 10 /Helvetica f (lookup) 3623 2260 w 10 /Times-Roman f (returns) 3947 2260 w (a) 4252 2260 w (pointer) 4324 2260 w (to) 4635 2260 w (a) 4741 2260 w (struc\255) 4813 2260 w (ture) 720 2380 w (that) 904 2380 w (looks) 1083 2380 w (like) 1329 2380 w 10 /Helvetica f (symtag) 1510 2380 w 16 /Helvetica f (.) 1833 2380 w 10 /Times-Roman f (And) 1931 2380 w (if) 2131 2380 w (we're) 2220 2380 w (going) 2474 2380 w (to) 2730 2380 w (use) 2836 2380 w (one) 2997 2380 w (of) 3169 2380 w (these) 3280 2380 w (functions,) 3513 2380 w (we) 3938 2380 w (have) 4082 2380 w (to) 4298 2380 w (make) 4404 2380 w (a) 4648 2380 w (declara\255) 4720 2380 w (tion where we use it, as we did in) 720 2500 w 10 /Helvetica f (main) 2082 2500 w 10 /Times-Roman f (above.) 2324 2500 w (Notice th parallelism between the declarations) 970 2656 w 10 /Helvetica f (struct) 1440 2826 w (symtag) 1720 2826 w 14 /Helvetica f (*) 2078 2875 w 10 /Helvetica f (lookup\() 2133 2826 w (\);) 2497 2826 w (struct) 1440 2946 w (symtag) 1720 2946 w 14 /Helvetica f (*) 2078 2995 w 10 /Helvetica f (psym;) 2133 2946 w 10 /Times-Roman f (In) 720 3116 w (effect,) 832 3116 w (this) 1112 3116 w (says) 1286 3116 w (that) 1487 3116 w 10 /Helvetica f (lookup\( \)) 1669 3116 w 10 /Times-Roman f (and) 2088 3116 w 10 /Helvetica f (psym) 2264 3116 w 10 /Times-Roman f (are) 2532 3116 w (both) 2682 3116 w (used) 2889 3116 w (the) 3101 3116 w (same) 3252 3116 w (way) 3486 3116 w 10 /S f (_) 3681 3116 w 10 /Times-Roman f (as) 3761 3116 w (a) 3874 3116 w (pointer) 3948 3116 w (to) 4261 3116 w (a) 4369 3116 w (strcture) 4443 3116 w 10 /S f (_) 4772 3116 w 10 /Times-Roman f (even) 4852 3116 w (though one is a variable and the other is a function.) 720 3236 w 10 /Helvetica f (21. Initialization of Variables) 720 3476 w 10 /Times-Roman f (An) 970 3632 w (external) 1129 3632 w (variable) 1487 3632 w (may) 1845 3632 w (be) 2054 3632 w (initialized) 2185 3632 w (at) 2622 3632 w (compile) 2731 3632 w (time) 3090 3632 w (by) 3306 3632 w (following) 3444 3632 w (its) 3871 3632 w (name) 4004 3632 w (with) 4258 3632 w (an) 4474 3632 w (initializing) 4606 3632 w (value) 720 3752 w (when) 963 3752 w (it) 1206 3752 w (is) 1289 3752 w (defined.) 1383 3752 w (The) 1759 3752 w (initializing) 1941 3752 w (value) 2402 3752 w (has) 2645 3752 w (to) 2805 3752 w (be) 2910 3752 w (something) 3031 3752 w (whose) 3475 3752 w (value) 3757 3752 w (is) 4000 3752 w (known) 4093 3752 w (at) 4391 3752 w (compile) 4489 3752 w (time,) 4837 3752 w (like a constant.) 720 3872 w 10 /Helvetica f (int) 1080 4042 w (x) 1440 4042 w (0;) 1800 4042 w (/) 2160 4042 w 14 /Helvetica f (*) 2188 4091 w 10 /Helvetica f ("0") 2278 4042 w (could) 2441 4042 w (be) 2716 4042 w (any) 2863 4042 w (constant) 3060 4042 w 14 /Helvetica f (*) 3475 4091 w 10 /Helvetica f (/) 3530 4042 w (int) 1080 4162 w (a) 1440 4162 w 10 /S f (\242) 1800 4162 w 10 /Helvetica f (a) 1825 4162 w 10 /S f (\242) 1881 4162 w 10 /Helvetica f (;) 1906 4162 w (char) 1080 4282 w (flag) 1440 4282 w (0177;) 1800 4282 w (int) 1080 4402 w 14 /Helvetica f (*) 1440 4451 w 10 /Helvetica f (p) 1495 4402 w (&y[1];) 1800 4402 w (/) 2160 4402 w 14 /Helvetica f (*) 2188 4451 w 10 /Helvetica f (p) 2278 4402 w (now) 2369 4402 w (points) 2588 4402 w (to) 2891 4402 w (y[1]) 3010 4402 w 14 /Helvetica f (*) 3207 4451 w 10 /Helvetica f (/) 3262 4402 w 10 /Times-Roman f (An external array can be initialized by following its name with a list of initializations enclosed in braces:) 720 4572 w 10 /Helvetica f (int) 1080 4742 w (x[4]) 1440 4742 w ({0,1,2,3};) 1800 4742 w (/) 2880 4742 w 14 /Helvetica f (*) 2908 4791 w 10 /Helvetica f (makes) 2998 4742 w (x[i]) 3328 4742 w (=) 3491 4742 w (i) 3584 4742 w 14 /Helvetica f (*) 3641 4791 w 10 /Helvetica f (/) 3696 4742 w (int) 1080 4862 w (y[) 1440 4862 w (]) 1553 4862 w ({0,1,2,3};) 1800 4862 w (/) 2880 4862 w 14 /Helvetica f (*) 2908 4911 w 10 /Helvetica f (makes) 2998 4862 w (y) 3328 4862 w (big) 3413 4862 w (enough) 3582 4862 w (for) 3953 4862 w (4) 4105 4862 w (values) 4196 4862 w 14 /Helvetica f (*) 4521 4911 w 10 /Helvetica f (/) 4576 4862 w (char) 1080 4982 w 14 /Helvetica f (*) 1440 5031 w 10 /Helvetica f (msg) 1495 4982 w ("syntax) 1800 4982 w (error\\n";) 2161 4982 w (/) 2880 4982 w 14 /Helvetica f (*) 2908 5031 w 10 /Helvetica f (braces) 2998 4982 w (unnecessary) 3334 4982 w (here) 3938 4982 w 14 /Helvetica f (*) 4174 5031 w 10 /Helvetica f (/) 4229 4982 w (char) 1080 5102 w 14 /Helvetica f (*) 1310 5151 w 10 /Helvetica f (keyword[) 1365 5102 w (]{) 1801 5102 w ("if",) 1440 5222 w ("else",) 1440 5342 w ("for",) 1440 5462 w ("while",) 1440 5582 w ("break",) 1440 5702 w ("continue",) 1440 5822 w (0) 1440 5942 w (};) 1080 6062 w 10 /Times-Roman f (This) 720 6232 w (last) 927 6232 w (one) 1095 6232 w (is) 1268 6232 w (very) 1364 6232 w (useful) 1570 6232 w 10 /S f (_) 1843 6232 w 10 /Times-Roman f (it) 1922 6232 w (makes) 2007 6232 w 10 /Helvetica f (keyword) 2294 6232 w 10 /Times-Roman f (an) 2696 6232 w (array) 2819 6232 w (of) 3052 6232 w (pointers) 3164 6232 w (to) 3515 6232 w (character) 3622 6232 w (strings,) 4015 6232 w (with) 4336 6232 w (a) 4543 6232 w (zero) 4616 6232 w (at) 4816 6232 w (the) 4918 6232 w (end) 720 6352 w (so) 890 6352 w (we) 1005 6352 w (can) 1147 6352 w (identify) 1311 6352 w (the) 1648 6352 w (last) 1796 6352 w (element easily.) 1961 6352 w (A simple lookup routine could scan this until it either finds a) 2610 6352 w (match or encounters a zero keyword pointer:) 720 6472 w 10 /Helvetica f (lookup\(str\)) 1080 6642 w (/) 2160 6642 w 14 /Helvetica f (*) 2188 6691 w 10 /Helvetica f (search) 2278 6642 w (for) 2614 6642 w (str) 2766 6642 w (in) 2912 6642 w (keyword[) 3025 6642 w (]) 3461 6642 w 14 /Helvetica f (*) 3524 6691 w 10 /Helvetica f (/) 3579 6642 w (char) 1185 6762 w 14 /Helvetica f (*) 1415 6811 w 10 /Helvetica f (str;) 1470 6762 w ({) 1644 6762 w (int) 1440 6882 w (i,j,r;) 1581 6882 w (for\() 1440 7002 w (i=0;) 1625 7002 w (keyword[i]) 1824 7002 w (!=) 2310 7002 w (0;) 2431 7002 w (i) 2550 7002 w 10 /Times-Roman f (++) 2572 7002 w 10 /Helvetica f (\)) 2684 7002 w ({) 2752 7002 w (for\() 1800 7122 w (j=0;) 1985 7122 w (\(r=keyword[i][j]\)) 2184 7122 w 10 /Times-Roman f (==) 2905 7122 w 10 /Helvetica f (str[j]) 3052 7122 w (&&) 3276 7122 w (r) 3445 7122 w (!=) 3513 7122 w 10 /S f (\242) 3634 2000 7122 w 10 /Helvetica f (\\0) 3659 7122 w 10 /S f (\242) 3743 7122 w 10 /Helvetica f (;) 3768 7122 w (j) 3831 7122 w 10 /Times-Roman f (++) 3853 7122 w 10 /Helvetica f (\);) 4000 7122 w (if\() 1800 7242 w (r) 1918 7242 w 10 /Times-Roman f (==) 1986 7242 w 10 /Helvetica f (str[j]) 2133 7242 w (\)) 2357 7242 w cleartomark showpage saveobj restore %%EndPage: 20 20 %%Page: 21 21 /saveobj save def mark 21 pagesetup 10 /Helvetica f (C ) 720 360 w (Tutorial) 827 360 w 10 /S f (-) 2914 360 w 10 /Helvetica f (21 ) 3004 360 w 10 /S f (-) 3151 360 w 10 /Helvetica f (return\(i\);) 2160 840 w (}) 1440 960 w (return\() 1440 1080 w 10 /S f (-) 1735 1080 w 10 /Helvetica f (1\);) 1790 1080 w (}) 1080 1200 w 10 /Times-Roman f (Sorry ) 970 1406 w 10 /S f (_) 1217 1406 w 10 /Times-Roman f (neither local variables nor structures can be initialized.) 1292 1406 w 10 /Helvetica f (22. Scope Rules: Who Knows About What) 720 1646 w 10 /Times-Roman f (A) 970 1802 w (complete) 1070 1802 w (C) 1464 1802 w (program) 1559 1802 w (need) 1925 1802 w (not) 2141 1802 w (be) 2297 1802 w (compiled) 2419 1802 w (all) 2820 1802 w (at) 2949 1802 w (once;) 3050 1802 w (the) 3295 1802 w (source) 3446 1802 w (text) 3735 1802 w (of) 3914 1802 w (the) 4026 1802 w (program) 4177 1802 w (may) 4544 1802 w (be) 4745 1802 w (kept) 4868 1802 w (in) 720 1922 w (several) 832 1922 w (files,) 1148 1922 w (and) 1379 1922 w (previously) 1557 1922 w (compiled) 2013 1922 w (routines) 2419 1922 w (may) 2775 1922 w (be) 2981 1922 w (loaded) 3109 1922 w (from) 3409 1922 w (libraries.) 3637 1922 w (How) 4048 1922 w (do) 4276 1922 w (we) 4410 1922 w (arrange) 4559 1922 w (that) 4890 1922 w (data) 720 2042 w (gets) 920 2042 w (passed) 1115 2042 w (from) 1415 2042 w (one) 1643 2042 w (routine) 1821 2042 w (to) 2138 2042 w (another?) 2250 2042 w (We) 2653 2042 w (have) 2826 2042 w (already) 3049 2042 w (seen) 3377 2042 w (how) 3589 2042 w (to) 3796 2042 w (use) 3909 2042 w (function) 4077 2042 w (arguments) 4445 2042 w (and) 4896 2042 w (values,) 720 2162 w (so) 1029 2162 w (let) 1147 2162 w (us) 1276 2162 w (talk) 1394 2162 w (about) 1573 2162 w (external) 1824 2162 w (data.) 2174 2162 w (Warning:) 2419 2162 w (the) 2825 2162 w (words) 2975 2162 w 10 /Times-Italic f (declaration) 3247 2162 w 10 /Times-Roman f (and) 3736 2162 w 10 /Times-Italic f (definition) 3908 2162 w 10 /Times-Roman f (are) 4320 2162 w (used) 4469 2162 w (precisely) 4680 2162 w (in this section; don't treat them as the same thing.) 720 2282 w (A) 970 2438 w (major) 1068 2438 w (shortcut) 1327 2438 w (exists) 1675 2438 w (for) 1929 2438 w (making) 2072 2438 w 10 /Helvetica f (extern) 2402 2438 w 10 /Times-Roman f (declarations.) 2708 2438 w (If) 3267 2438 w (the) 3360 2438 w (definition) 3509 2438 w (of) 3925 2438 w (a) 4035 2438 w (variable) 4106 2438 w (appears) 4454 2438 w 10 /Times-Italic f (before) 4785 2438 w 10 /Times-Roman f (its use in some function, no) 720 2558 w 10 /Helvetica f (extern) 1848 2558 w 10 /Times-Roman f (declaration is needed within the function.) 2152 2558 w (Thus, if a file contains) 3855 2558 w 10 /Helvetica f (f1\() 1080 2728 w (\)) 1232 2728 w ({) 1300 2728 w 16 /Helvetica f (...) 1368 2728 w 10 /Helvetica f (}) 1538 2728 w (int) 1080 2898 w (foo;) 1221 2898 w (f2\() 1080 3068 w (\)) 1232 3068 w ({) 1300 3068 w 16 /Helvetica f (...) 1368 3068 w 10 /Helvetica f (foo) 1538 3068 w (=) 1713 3068 w (1;) 1806 3068 w 16 /Helvetica f (...) 1925 3068 w 10 /Helvetica f (}) 2095 3068 w (f3\() 1080 3238 w (\)) 1232 3238 w ({) 1300 3238 w 16 /Helvetica f (...) 1368 3238 w 10 /Helvetica f (if) 1538 3238 w (\() 1623 3238 w (foo) 1691 3238 w (\)) 1866 3238 w 16 /Helvetica f (...) 1934 3238 w 10 /Helvetica f (}) 2104 3238 w 10 /Times-Roman f (no) 720 3408 w (declaration) 851 3408 w (of) 1325 3408 w 10 /Helvetica f (foo) 1442 3408 w 10 /Times-Roman f (is) 1613 3408 w (needed) 1711 3408 w (in) 2024 3408 w (either) 2133 3408 w 10 /Helvetica f (f2) 2394 3408 w 10 /Times-Roman f (or) 2509 3408 w (or) 2623 3408 w 10 /Helvetica f (f3,) 2741 3408 w 10 /Times-Roman f (because) 2885 3408 w (the) 3232 3408 w (external) 3386 3408 w (definition) 3739 3408 w (of) 4160 3408 w 10 /Helvetica f (foo) 4278 3408 w 10 /Times-Roman f (appears) 4450 3408 w (before) 4786 3408 w (them.) 720 3528 w (But if) 995 3528 w 10 /Helvetica f (f1) 1254 3528 w 10 /Times-Roman f (wants to use) 1363 3528 w 10 /Helvetica f (foo,) 1885 3528 w 10 /Times-Roman f (it has to contain the declaration) 2078 3528 w 10 /Helvetica f (f1\() 1080 3698 w (\)) 1232 3698 w ({) 1300 3698 w (extern) 1440 3818 w (int) 1754 3818 w (foo;) 1895 3818 w 16 /Helvetica f (...) 1440 3938 w 10 /Helvetica f (}) 1080 4058 w 10 /Times-Roman f (This) 970 4264 w (is) 1180 4264 w (true) 1279 4264 w (also) 1466 4264 w (of) 1659 4264 w (any) 1774 4264 w (function) 1950 4264 w (that) 2316 4264 w (exists) 2499 4264 w (on) 2760 4264 w (another) 2893 4264 w (file) 3225 4264 w 10 /S f (_) 3391 4264 w 10 /Times-Roman f (if) 3474 4264 w (it) 3568 4264 w (wants) 3657 4264 w 10 /Helvetica f (foo) 3926 4264 w 10 /Times-Roman f (it) 4099 4264 w (has) 4188 4264 w (to) 4354 4264 w (use) 4465 4264 w (an) 4631 4264 w 10 /Helvetica f (extern) 4761 4264 w 10 /Times-Roman f (declaration) 720 4384 w (for) 1196 4384 w (it.) 1345 4384 w (\(If) 1484 4384 w (somewhere) 1616 4384 w (there) 2103 4384 w (is) 2335 4384 w (an) 2435 4384 w 10 /Helvetica f (extern) 2565 4384 w 10 /Times-Roman f (declaration) 2876 4384 w (for) 3351 4384 w (something,) 3499 4384 w (there) 3973 4384 w (must) 4204 4384 w (also) 4431 4384 w (eventually) 4624 4384 w (be an external definition of it, or you'll get an ``undefined symbol'' message.\)) 720 4504 w (There) 970 4660 w (are) 1242 4660 w (some) 1403 4660 w (hidden) 1654 4660 w (pitfalls) 1966 4660 w (in) 2284 4660 w (external) 2402 4660 w (declarations) 2763 4660 w (and) 3285 4660 w (definitions) 3469 4660 w (if) 3938 4660 w (you) 4040 4660 w (use) 4231 4660 w (multiple) 4405 4660 w (source) 4780 4660 w (files.) 720 4780 w (To avoid them, first, define and initialize each external variable only once in the entire set of files:) 967 4780 w 10 /Helvetica f (int) 1080 4950 w (foo) 1440 4950 w (0;) 1800 4950 w 10 /Times-Roman f (You) 720 5120 w (can) 928 5120 w (get) 1102 5120 w (away) 1260 5120 w (with) 1506 5120 w (multiple) 1720 5120 w (external) 2090 5120 w (definitions) 2447 5120 w (on) 2912 5120 w 8 /Times-Roman f (UNIX,) 3044 5120 w 10 /Times-Roman f (but) 3301 5120 w (not) 3466 5120 w (on) 3631 5120 w 8 /Times-Roman f (GCOS,) 3763 5120 w 10 /Times-Roman f (so) 4035 5120 w (don't) 4161 5120 w (ask) 4409 5120 w (for) 4579 5120 w (trouble.) 4732 5120 w (Multiple) 720 5240 w (initializations) 1095 5240 w (are) 1670 5240 w (illegal) 1821 5240 w (everywhere.) 2101 5240 w (Second,) 2645 5240 w (at) 2994 5240 w (the) 3096 5240 w (beginning) 3248 5240 w (of) 3678 5240 w (any) 3791 5240 w (file) 3965 5240 w (that) 4127 5240 w (contains) 4306 5240 w (functions) 4668 5240 w (needing) 720 5360 w (a) 1063 5360 w (variable) 1134 5360 w (whose) 1482 5360 w (definition) 1764 5360 w (is) 2181 5360 w (in) 2276 5360 w (some) 2382 5360 w (other) 2621 5360 w (file,) 2854 5360 w (put) 3040 5360 w (in) 3196 5360 w (an) 3302 5360 w 10 /Helvetica f (extern) 3427 5360 w 10 /Times-Roman f (declaration,) 3734 5360 w (outside) 4230 5360 w (of) 4547 5360 w (any) 4658 5360 w (func\255) 4830 5360 w (tion:) 720 5480 w 10 /Helvetica f (extern) 1080 5650 w (int) 1440 5650 w (foo;) 1800 5650 w (f1\() 1080 5820 w (\)) 1232 5820 w ({) 1300 5820 w 16 /Helvetica f (...) 1368 5820 w 10 /Helvetica f (}) 1538 5820 w (etc) 1185 5940 w 16 /Helvetica f (.) 1319 5940 w 10 /Times-Roman f (The) 970 6146 w 10 /Helvetica f (#include) 1154 6146 w 10 /Times-Roman f (compiler) 1554 6146 w (control) 1935 6146 w (line,) 2244 6146 w (to) 2445 6146 w 2000 (be) 2549 6146 w (discussed) 2669 6146 w (shortly,) 3078 6146 w (lets) 3407 6146 w (you) 3572 6146 w (make) 3748 6146 w (a) 3991 6146 w (single) 4062 6146 w (copy) 4328 6146 w (of) 4549 6146 w (the) 4659 6146 w (exter\255) 4808 6146 w (nal declarations for a program and then stick them into each of the source files making up the program.) 720 6266 w 10 /Helvetica f (23. #define, #include) 720 6506 w 10 /Times-Roman f (C provides a very limited macro facility.) 970 6662 w (You can say) 2643 6662 w 10 /Helvetica f (#define) 1080 6832 w (name) 1440 6832 w (something) 2160 6832 w 10 /Times-Roman f (and) 720 7002 w (thereafter) 892 7002 w (anywhere) 1301 7002 w (``name'') 1716 7002 w (appears) 2092 7002 w (as) 2424 7002 w (a) 2535 7002 w (token,) 2607 7002 w (``something'') 2882 7002 w (will) 3459 7002 w (be) 3643 7002 w (substituted.) 3765 7002 w (This) 4277 7002 w (is) 4484 7002 w (particularly) 4580 7002 w (useful in parametering the sizes of arrays:) 720 7122 w 10 /Helvetica f (#define) 1080 7292 w (ARRAYSIZE) 1440 7292 w (100) 2160 7292 w cleartomark showpage saveobj restore %%EndPage: 21 21 %%Page: 22 22 /saveobj save def mark 22 pagesetup 10 /Helvetica f (C ) 720 360 w (Tutorial) 827 360 w 10 /S f (-) 2914 360 w 10 /Helvetica f (22 ) 3004 360 w 10 /S f (-) 3151 360 w 10 /Helvetica f (int) 1440 840 w (arr[ARRAYSIZE];) 1800 840 w 16 /Helvetica f (...) 1475 960 w 10 /Helvetica f (while\() 1440 1080 w (i) 1736 1080 w 10 /Times-Roman f (++) 1758 1080 w 10 /Helvetica f (<) 1905 1080 w (ARRAYSIZE) 1998 1080 w (\)) 2601 1080 w 16 /Helvetica f (...) 2634 1080 w 10 /Times-Roman f (\(now we can alter the entire program by changing only the) 720 1250 w 10 /Helvetica f (define\)) 3087 1250 w 10 /Times-Roman f (or in setting up mysterious constants:) 3419 1250 w 10 /Helvetica f (#define) 1080 1420 w (SET) 1440 1420 w (01) 2160 1420 w (#define) 1080 1540 w (INTERRUPT) 1440 1540 w (02) 2160 1540 w (/) 2520 1540 w 14 /Helvetica f (*) 2548 1589 w 10 /Helvetica f (interrupt) 2638 1540 w (bit) 3041 1540 w 14 /Helvetica f (*) 3182 1589 w 10 /Helvetica f (/) 3237 1540 w (#define) 1080 1660 w (ENABLED) 1440 1660 w (04) 2160 1660 w 16 /Helvetica f (...) 1115 1780 w 10 /Helvetica f (if\() 1080 1900 w (x) 1198 1900 w (&) 1283 1900 w (\(SET) 1385 1900 w 10 /S f (\357) 1648 1900 w 10 /Helvetica f (INTERRUPT) 1732 1900 w 10 /S f (\357) 2339 1900 w 10 /Helvetica f (ENABLED\)) 2423 1900 w (\)) 2959 1900 w 16 /Helvetica f (...) 3027 1900 w 10 /Times-Roman f (Now) 720 2070 w (we) 950 2070 w (have) 1102 2070 w (meaningful) 1326 2070 w (words) 1817 2070 w (instead) 2097 2070 w (of) 2416 2070 w (mysterious) 2535 2070 w (constants.) 3010 2070 w (\(The) 3468 2070 w (mysterious) 3693 2070 w (operators) 4169 2070 w (`&') 4577 2070 w (\(AND\)) 4758 2070 w (and) 720 2190 w (`) 896 2190 w 10 /S f (|) 929 2190 w 10 /Times-Roman f (') 949 2190 w (\(OR\)) 1014 2190 w (will) 1251 2190 w (be) 1439 2190 w (covered) 1565 2190 w (in) 1912 2190 w (the) 2022 2190 w (next) 2176 2190 w (section.\)) 2380 2190 w (It's) 2778 2190 w (an) 2943 2190 w (excellent) 3069 2190 w (practice) 3460 2190 w (to) 3806 2190 w (write) 3915 2190 w (programs) 4151 2190 w (without) 4559 2190 w (any) 4896 2190 w (literal constants except in) 720 2310 w 10 /Helvetica f (#define) 1766 2310 w 10 /Times-Roman f (statements.) 2121 2310 w (There) 970 2466 w (are) 1234 2466 w (several) 1388 2466 w (warnings) 1703 2466 w (about) 2102 2466 w 10 /Helvetica f (#define) 2360 2466 w 16 /Helvetica f (.) 2690 2466 w 10 /Times-Roman f (First,) 2793 2466 w (there's) 3035 2466 w (no) 3339 2466 w (semicolon) 3472 2466 w (at) 3916 2466 w (the) 4021 2466 w (end) 4176 2466 w (of) 4353 2466 w (a) 4469 2466 w 10 /Helvetica f (#define;) 4549 2466 w 10 /Times-Roman f (all) 4940 2466 w (the) 720 2586 w (text) 870 2586 w (from) 1048 2586 w (the) 1270 2586 w (name) 1420 2586 w (to) 1664 2586 w (the) 1770 2586 w (end) 1920 2586 w (of) 2092 2586 w (the) 2203 2586 w (line) 2353 2586 w (\(except) 2530 2586 w (for) 2850 2586 w (comments\)) 2993 2586 w (is) 3464 2586 w (taken) 3558 2586 w (to) 3801 2586 w (be) 3906 2586 w (the) 4027 2586 w (``something''.) 4176 2586 w (When) 4802 2586 w (it's) 720 2706 w (put) 877 2706 w (into) 1034 2706 w (the) 1219 2706 w (text,) 1370 2706 w (blanks) 1575 2706 w (are) 1866 2706 w (placed) 2017 2706 w (around) 2307 2706 w (it.) 2614 2706 w (Good) 2750 2706 w (style) 3002 2706 w (typically) 3221 2706 w (makes) 3601 2706 w (the) 3886 2706 w (name) 4038 2706 w (in) 4284 2706 w (the) 4392 2706 w 10 /Helvetica f (#define) 4547 2706 w 10 /Times-Roman f (up\255) 4907 2706 w (per) 720 2826 w (case) 884 2826 w 10 /S f (_) 1092 2826 w 10 /Times-Roman f (this) 1179 2826 w (makes) 1361 2826 w (parameters) 1653 2826 w (more) 2127 2826 w (visible.) 2369 2826 w (Definitions) 2723 2826 w (affect) 3210 2826 w (things) 3473 2826 w (only) 3755 2826 w (after) 3970 2826 w (they) 4189 2826 w (occur,) 4398 2826 w (and) 4681 2826 w (only) 4862 2826 w (within) 720 2946 w (the) 1007 2946 w (file) 1160 2946 w (in) 1324 2946 w (which) 1433 2946 w (they) 1708 2946 w (occur.) 1911 2946 w (Defines) 2213 2946 w (can't) 2554 2946 w (be) 2784 2946 w (nested.) 2909 2946 w (Last,) 3245 2946 w (if) 3474 2946 w (there) 3567 2946 w (is) 3798 2946 w (a) 3897 2946 w 10 /Helvetica f (#define) 3976 2946 w 10 /Times-Roman f (in) 4338 2946 w (a) 4448 2946 w (file,) 4524 2946 w (then) 4714 2946 w (the) 4918 2946 w (first character of the file) 720 3066 w 10 /Times-Italic f (must) 1708 3066 w 10 /Times-Roman f (be a `#', to signal the preprocessor that definitions exist.) 1922 3066 w (The) 970 3342 w (other) 1156 3342 w (control) 1392 3342 w (word) 1706 3342 w (known) 1942 3342 w (to) 2245 3342 w (C) 2354 3342 w (is) 2453 3342 w 10 /Helvetica f (#include) 2555 3342 w 16 /Helvetica f (.) 2929 3342 w 10 /Times-Roman f (To) 3031 3342 w (include) 3174 3342 w (one) 3500 3342 w (file) 3676 3342 w (in) 3841 3342 w (your) 3951 3342 w (source) 4166 3342 w (at) 4458 3342 w (compilation) 4562 3342 w (time, say) 720 3462 w 10 /Helvetica f (#include) 1080 3632 w ("filename") 1489 3632 w 10 /Times-Roman f (This) 720 3802 w (is) 924 3802 w (useful) 1017 3802 w (for) 1287 3802 w (putting) 1429 3802 w (a) 1739 3802 w (lot) 1809 3802 w (of) 1942 3802 w (heavily) 2052 3802 w (used) 2373 3802 w (data) 2583 3802 w (definitions) 2776 3802 w (and) 3231 3802 w 10 /Helvetica f (#define) 3405 3802 w 10 /Times-Roman f (statements) 3762 3802 w (at) 4211 3802 w (the) 4310 3802 w (beginning) 4459 3802 w (of) 4886 3802 w (a) 4996 3802 w (file) 720 3922 w (to) 883 3922 w (be) 991 3922 w (compiled.) 1114 3922 w (As) 1565 3922 w (with) 1705 3922 w 10 /Helvetica f (#define,) 1915 3922 w 10 /Times-Roman f (the) 2302 3922 w (first) 2453 3922 w (line) 2643 3922 w (of) 2822 3922 w (a) 2934 3922 w (file) 3007 3922 w (containing) 3169 3922 w (a) 3620 3922 w 10 /Helvetica f (#include) 3696 3922 w 10 /Times-Roman f (has) 4099 3922 w (to) 4261 3922 w (begin) 4368 3922 w (with) 4619 3922 w (a) 4826 3922 w (`#'.) 4899 3922 w (And) 720 4042 w 10 /Helvetica f (#include) 920 4042 w 10 /Times-Roman f (can't be nested ) 1319 4042 w 10 /S f (_) 1942 4042 w 10 /Times-Roman f (an included file can't contain another) 2017 4042 w 10 /Helvetica f (#include) 3533 4042 w 16 /Helvetica f (.) 3907 4042 w 10 /Helvetica f (24. Bit Operators) 720 4282 w 10 /Times-Roman f (C has several operators for logical bit\255operations.) 970 4438 w (For example,) 2991 4438 w 10 /Helvetica f (x) 1080 4608 w (=) 1165 4608 w (x) 1258 4608 w (&) 1343 4608 w (0177;) 1445 4608 w 10 /Times-Roman f (forms) 720 4778 w (the) 984 4778 w (bit\255wise) 1137 4778 w 8 /Times-Roman f (AND) 1485 4778 w 10 /Times-Roman f (of) 1691 4778 w 10 /Helvetica f (x) 1809 4778 w 10 /Times-Roman f (and) 1891 4778 w (0177,) 2067 4778 w (effectively) 2324 4778 w (retaining) 2782 2000 4778 w (only) 3169 4778 w (the) 3379 4778 w (last) 3533 4778 w (seven) 3704 4778 w (bits) 3963 4778 w (of) 4140 4778 w 10 /Helvetica f (x) 4258 4778 w 16 /Helvetica f (.) 4308 4778 w 10 /Times-Roman f (Other) 4410 4778 w (operators) 4669 4778 w (are) 720 4898 w 10 /S f (|) 1080 5068 w 10 /Times-Roman f (inclusive) 1440 5068 w (OR) 1832 5068 w (\223) 1080 5188 w (\(circumflex\)) 1440 5188 w (exclusive) 1969 5188 w (OR) 2377 5188 w (\224) 1080 5308 w (\(tilde\)) 1440 5308 w (1) 1715 5308 w 10 /S f (\242) 1765 5308 w 10 /Times-Roman f (s) 1790 5308 w (complement) 1860 5308 w (!) 1080 5428 w (logical) 1440 5428 w (NOT) 1743 5428 w (<<) 1080 5548 w (left) 1440 5548 w (shift) 1604 5548 w (\(as) 1813 5548 w (in) 1960 5548 w (x<<2\)) 2069 5548 w (>>) 1080 5668 w (right) 1440 5668 w (shift) 1660 5668 w (\(arithmetic) 2160 5668 w (on) 2629 5668 w (PDP\25511;) 2760 5668 w (logical) 3136 5668 w (on) 3439 5668 w (H6070,) 3570 5668 w (IBM360\)) 3898 5668 w 10 /Helvetica f (25. Assignment Operators) 720 5958 w 10 /Times-Roman f (An) 970 6114 w (unusual) 1122 6114 w (feature) 1463 6114 w (of) 1769 6114 w (C) 1882 6114 w (is) 1979 6114 w (that) 2076 6114 w (the) 2256 6114 w (normal) 2408 6114 w (binary) 2722 6114 w (operators) 3008 6114 w (like) 3410 6114 w (`+',) 3591 6114 w (`) 3769 6114 w 10 /S f (-) 3802 6114 w 10 /Times-Roman f (',) 3857 6114 w (etc.) 3946 6114 w (can) 4143 6114 w (be) 4312 6114 w (combined) 4437 6114 w (with) 4862 6114 w (the assignment operator `=' to form new assignment operators.) 720 6234 w (For example,) 3280 6234 w 10 /Helvetica f (x) 1080 6404 w (=) 1165 6404 w 10 /S f (-) 1223 6404 w 10 /Helvetica f (10;) 1313 6404 w 10 /Times-Roman f (uses the assignment operator `=) 720 6574 w 10 /S f (-) 1985 6574 w 10 /Times-Roman f (' to decrement) 2040 6574 w 10 /Helvetica f (x) 2644 6574 w 10 /Times-Roman f (by 10, and) 2719 6574 w 10 /Helvetica f (x) 1080 6744 w (=&) 1165 6744 w (0177) 1325 6744 w 10 /Times-Roman f (forms) 720 6914 w (the) 981 6914 w 8 /Times-Roman f (AND) 1126 6914 w 10 /Times-Roman f (of) 1328 6914 w 10 /Helvetica f (x) 1442 6914 w 10 /Times-Roman f (and) 1520 6914 w (0177.) 1693 6914 w (This) 1972 6914 w (convention) 2179 6914 w (is) 2652 6914 w (a) 2748 6914 w (useful) 2821 6914 w (notational) 3094 6914 w (shortcut,) 3523 6914 w (particularly) 3899 6914 w (if) 4388 6914 w 10 /Helvetica f (x) 4481 6914 w 10 /Times-Roman f (is) 4560 6914 w (a) 4656 6914 w (compli\255) 4729 6914 w (cated expression.) 720 7034 w (The classic example is summing an array:) 1457 7034 w 10 /Helvetica f (for\() 1080 7204 w (sum=i=0;) 1265 7204 w (i