home *** CD-ROM | disk | FTP | other *** search
/ nextcube.org / www.nextcube.org.tar / www.nextcube.org / board / bbs.php3?board=board&line=thred&mode=view&id=164&fld=&nws=&page=49&keyword=&flag=&a_o=.orig < prev    next >
Text File  |  2010-08-17  |  51KB  |  339 lines

  1. <html><head><title>NeXTcube - ABookOnC Chapter 1 - 1.3</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'><link rel='stylesheet' type='text/css' href='./css/style.css'><link rel='shortcut icon' href='/images/favicon.ico'><link rel='alternate' type='application/rss+xml' title='NeXTcube RSS Feed' href='/board/rss2.php?items=active'><script type='text/javascript' src='./css/nextcube.js'></script></head>
  2.  
  3. <body bgcolor=#ffffff text=#000000 link=#000000 alink=#000000 vlink=#000000  onload='imgSizeConv(600);'>
  4.  
  5. <div id='menu'><table border=0 width=120 height=100% cellpadding=0 cellspacing=0 bgcolor=#000000><tr><td height=40 colspan=2></td></tr><tr><td width=16></td><td align=left valign=top><a href=?board=news&line=rdate&fld=&nws=><img src=/images/news_t.gif border=0></a><br><br><br><a href=?board=board&line=rdate&fld=&nws=><img src=/images/board_t.gif border=0></a><br><br><br><a href=?board=doc&line=subject&fld=&nws=><img src=/images/doc_t.gif border=0></a><br><br><br><a href=?board=photo&line=reg_date&fld=&nws=><img src=/images/photo_t.gif border=0></a><br><br><br><a href=?board=image&line=reg_date&fld=&nws=><img src=/images/image_t.gif border=0></a><br><br><br><a href=?board=pub&line=subject&fld=&nws=><img src=/images/pub_t.gif border=0></a><br><br><br></td></tr><tr><td align=center valign=bottom colspan=2><img src='/counter/digit/code39/0.gif'><img src='/counter/digit/code39/0.gif'><img src='/counter/digit/code39/0.gif'><img src='/counter/digit/code39/2.gif'><img src='/counter/digit/code39/2.gif'><img src='/counter/digit/code39/9.gif'><img src='/counter/digit/code39/3.gif'><br><br><img src=/images/contactme.gif border=0></td></tr><tr><td height=40 colspan=2></td></tr></table></div>
  6.  
  7. <div id='main'><table width=100% height=100% border=0 cellpadding=0 cellspacing=0 align=center><tr><td height=40></td></tr><tr><td align=center valign=top><a href='#page_bottom' title='Go to Bottom of Page'><img src='/images/knowhow2.gif' id='knowhow2' border=0></a><a href='https://www.pbank.co.kr/svc/guest_remit/pop_remit_main.jsp?fix=46516&b_bankbook=378273812&fbid=' title='Pbank Donate'><img src='/images/pbank_logo.gif' id='pbank' border=0></a><form action='https://www.paypal.com/cgi-bin/webscr' method='post'><input type='hidden' name='cmd' value='_s-xclick'><input type='hidden' name='hosted_button_id' value='9050272'><input type='image' src='/images/paypal_logo.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!' title='Paypal Donate' id='paypal'><img alt='' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'></form><table width=100% border=0 cellpadding=0 cellspacing=1 align=center><tr><td align=center><img src='/images/board.gif'></td></tr></table><br><br>
  8.  
  9. <table bgcolor=#ffffff width=100% border=0 cellpadding=2 cellspacing=1 align=center><tr height=24 bgcolor=#666666><td width=100% align=center nowrap><font color=#ffffff><b>ABookOnC Chapter 1 - 1.3</b></font></td></tr></table><a name="0"></a><table bgcolor=#ffffff width=100% border=0 cellpadding=4 cellspacing=0 align=center><tr height=24 bgcolor=#eeeeee><td width=50% align=left nowrap>òµ·ºƒÃ: <a href="mailto:Narzisse@borahome.net">ºÁÚòÚÀò†©</a></td><td width=50% align=right nowrap><a href='/board/bbs.php3?board=board&line=thred&mode=del&id=164&rid=164&fld=&nws=&page=49&keyword=&flag=&a_o=' onclick="return confirm('ò©Õº§Ð òÁ›ò©ÞóÕÚòËÞŒ†©òʦºËÈŒ„Ì?')">[òÁ›ò©Þ]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=modi&id=164&rid=164&fld=&nws=&page=49&keyword=&flag=&a_o='>[òÈÚò©Õ]</a> 2001-01-21 04:13:52</td></tr></table><table bgcolor=#ffffff width=100% border=0 cellpadding=10 cellspacing=1 align=center><tr bgcolor=#ffffff><td>Chapter 1 
  10. <br>
  11. <br>An Overview of C 
  12. <br>
  13. <br>This chapter gives an overview of the C Programming language. A series of programs is presented, and the elements of each program are carefully explained. 
  14. <br>
  15. <br>òµ· ò–ÕóîºÊÔ C óÔú¡ÞŒ•‚º×Úº®ÍòÖ‚òÖ·òµÚ Œ®ÞòÜÔº¥… º‡·òÙ‹ò⁄ ºË⁄. óÔú¡ÞŒ•‚º×¤ºÓ⁄òµÚ òËÞºƒ‹òƒÈ óÕÚºÁÚŒ®  òÅÌŒ®ÞºÐÚòÖ·ò§ Œ‡©, Œ®ÀŒ®ÀòµÚ óÔú¡ÞŒ•‚º×¤òµÚ òÜÔòÅ̺Ó⁄òµ  òË©ò⁄ÑóÕÚŒ†Ì òÃ⁄º“ĺÐÚòÖ·ò§ÃºË⁄. 
  16. <br>
  17. <br>Experimentation and interaction are emphasized throughout the text. In this chapter, we emphasize how to use the basic input/output functions of C. 
  18. <br>
  19. <br>òË⁄óÙÚŒ‡… ò×ÑòÜ’òµ  textº¥… óŦóÕ·òÃÞ Œ®Õò¡®ºÐÚòÖ· ò§ÃºË⁄.(Œ•‚º÷‹ºËÈŒ„Ì òË⁄ò©Þ compile Œ‡… Œ•‚Œ†ÂòµÚ òË⁄óÖÉòµ· Œ®Õò¡®ºÐÚòÖ· ò§ÃºË⁄.) 
  20. <br>òµ· ò–ÕóîòÙÐòÃÞ òÜ®ºƒ‹ºÊÔ CòµÚ Œ‚®º‡‚ óÕ¤òÈÚ(input/output functions)ºÓ⁄òµ· òÖ·ºÖ»Œ†Ì òÁ‹òÜ’ºÐÚòÖ·ò§ ºÊÔò§  Œ®Õò¡®óÕÞºË⁄. 
  21. <br>
  22. <br>Note carefully that all our C code also serves as C++ code and that all the ideas we discuss hold for c++ as well as for C. Of course, the C++ programmer has available a richer set of tools and techniques out of which programs can be constructed. (See Chapter 13, í ÞMoving from C to C++.í µ) 
  23. <br>
  24. <br>òË©ò⁄ÑóÕÚŒ†Ì ºÄ‚óÊ‚óÕ·ºµ…. òÜ®ºƒ‹òµÚ º“¤ºÓ© C ò‰ÔºÓÞºÊÔ, C++ code Œ•‚ºƒ‹Œ‡© CòÛ  º§Èò®‹Œ® ò§ º¡Þ C++òµÃ òÞ©ò§ ,º‡·òÈÚ(hold for) óÕÚŒ‚® òÞÃóÕ· ºÄ…òµÚóÕÚºÊÔ º“¤ºÓ© òÕÃòµ·ºÔÔòÖ·ºÓ⁄òµÚ òÙ›óÕ©òµÃ,(Œ¦‹òË⁄òµÃ)(serve as) ºÚÐóÕÞ óÕÞºË⁄. 
  25. <br>º‹…º¡©, C++óÔú¡ÞŒ•‚º×Úº¤‚ºÊÔ ò§ÞòÙ‹ò§È òÈÚ ò×ȺÊÔ óÔú¡ÞŒ•‚º×¤ºÓ⁄òµÚ º®ÖòÙÐòÃÞ,(òÛ‚òÙÐ) óÒͺ¶ óÕÞ tools Œ‡… techniquesº¥… Œ®ÖºÊÔ Œ†Âòµ· Œ® ºÊ¥óÕÚºË⁄. 
  26. <br>
  27. <br>Except for Section 1.8, í ÞArrays, Strings, and Pointers,í µ on page 36, everyone should read all the material in this chapter. Any reader who has had experience with arrays, pointers, and files in some other language can read all the sections of this chapter to get a more complete overview of C. 
  28. <br>
  29. <br>36pageòÙРò×ȺÊÔ1.8ò×¥ í Þº®®òÙ·ºÓ⁄, òÊ⁄óÊ‚º§ÀºÓ⁄, óÏ‹òµ‚óîºÓ⁄,í µ òµÃ ò©ÞòÛ‚óÕÚŒ‡©ºÊÔ, º“¤ºÓ© òµ·ºÓ⁄òµ  òµ· ò–ÕóîòµÚ º“¤ºÓ© òÝк£Ì(ò×к£Ì,Œ¦‹òÖòÜÔòÅÌ)º¥… òµ‰òÖ·òÕ…º§Ì óÕÞºË⁄. 
  30. <br>òÖ·ºÖ⁄ ºÏÄò×кÓ⁄òÙÐŒ†Ì ò×ÈòÖ·òÃÞºÊÔ, Œ•‚º÷‹ºËÈŒ„Ì º®®òÙ·, óÏ‹òµ‚óî, óÌÌòµ…òÙРºÌ óÕ·òÃÞ òÖ·ºÖ⁄ ºË⁄º¥‚ languageòÕÈòÙÐòÃÞòµÚ Œ†‰óÙÚòµÃ òµ·ºfl‚ Œ® ò§ Œ‡© ò×ȺÍÚ ºÏÄò×кÓ⁄òµ  C òµÚ Œ®ÞòÜÔº¥…(overview of C) ºÍÔ òÛú†‰óÕÚŒ†Ì òÖ»Œ‚® òÞÃóÕ·òÃÞ òµ· ò–ÕóîòµÚ º“¤ºÓ© ò×Ñòµ  ºË¤òÝкÓ⁄òµÃ(sections) òµ‰òµÃ òÈÚ ò×ȺË⁄. 
  31. <br>(Œ•‚º÷‹ºËÈŒ„Ì º®®òÙ·, óÏ‹òµ‚óî, óÌÌòµ…òÙРºÌ óÕÞ Œ†‰óÙÚòµ· ò×ÈòÞ…º’· 1.8ò×¥ Œ„Ìò§ ºÏàòµ‰òµÃ òÈÚ ò×ȺÊԺͮ, Cº¥… ò†ÚòµÌ ò©ÑóÕÚºÊÔ ºÏÄò×кÓ⁄òµ  ò¦ÞòÅÌóÕÞ 1.8ò×¥òµÃ ò©ÞòÛ‚óÕÞ ºË⁄º¥‚ ºÁÚº¤‚ò§  sections òµÃ º“¤ºÑРòµ‰òÖ·òÕ…º§Ì óÕÞºË⁄ºÊÔ òÖÚŒ‚®òµ‚Œ–® Œ®ÛòʦºËȺË⁄. ^_^) 
  32. <br>
  33. <br>Others can come back to material when they feel they are ready. Everyone should read this chapter with the understanding that technical details and further explanations will come in later chapter. 
  34. <br>
  35. <br>ºË⁄º¥‚ òµ·ºÓ⁄òµ  Œ•‚ºÓ⁄òµ· ò⁄ º„ÃŒ®  ºÐÚòÙȺË⁄Œ‡© ºÊкÁàºÕÌ ºË⁄òËÞ òÝк£Ì,(ºÁ·òÜ’òÞ…)(material)º¡Þ ºÏÌòÕàòÚ‹ òÈÚ ò×ȺË⁄. 
  36. <br>(òµ· ºÁ·òÜ’ ºÚÐóÕÞ 1.8ò×¥òµÃ Œ•‚ºÂ¥ ºÃÚòÖ·Œ®Ã ºÏÄò×кÓ⁄òµ· ºÁÚò⁄ÑòÙРº®®òÙ·Œ‡…, óÏ‹òµ‚óî, óÌÌòµ… ºÓ–òÙРºÌ óÕ·òÃÞ òÖ·ºÊРò©ÕºÏàòÕÌŒ‡© 
  37. <br>ºÁÞ ºË⁄òµÌòÙР1.8ò×¥òÞ…º¡Þ ºË⁄òËÞ ºÏÌòÕÃòÛ  ºÁ·òÜ’òµÃ º‡… òÈÚ ò×ȺË⁄ºÊÔ òÖÚŒ‚®ò×ĺËȺË⁄.) 
  38. <br>º“¤ºÓ© òµ·ºÓ⁄òµ  Œ‚®òÈ©ò©Àòµ‚ òº¶ òÁ‹óÕ›Œ‡… ºÍÔ º§Îòµ  òÃ⁄º“ĺÓ⁄òµ· ºË⁄òµÌ ò–ÕóîòÙÐòÃÞ Œ‡ÃòÅÍ ºÐÞºË⁄(will come)ºÊÔ òµ·óÕ·òÛ  ºÍÔº¶ÈòÖ· º‡‚ ò–Õó… òµ‰òÖ·òÕ… óÕ© Œ†Âòµ·ºË⁄. 
  39. <br>
  40. <br>1.1 Programming and preparation 
  41. <br>
  42. <br>Resident on the machine is a collection of special programs called the operating system. Commonly available operating systems include MS-DOS. OS/2, and UNIX. An operating system manages machine resources, provides software for the user, and acts as an interface between the user and hardware. 
  43. <br>
  44. <br>º¤‚òË©òÞÃòÙРò¡·ò׋óÕÚºÊÔ(òÁ·òÕÃŒ® ºÊÔ, Resident) óÊ„º‡ÃóÕÞ óÔú¡ÞŒ•‚º×¤ºÓ⁄òµÚ ò§ÑóÕ’ò†·º¥… òÜ·òÚÀò†·ò©Þ(operating system) ºµ… º¶ º¥‚ºË⁄. òµ…º®Úò©ÀòÞ…º¡Þ Œ® ºÊ¥óÕÞ òÜ·òÚÀò†·ò©ÞºÊÔ MS-DOS, OS/2, and UNIXº¥… óÏ‹óÕ¤óÕÞºË⁄(òµ…ò»«ºÊÔºË⁄). óÕÚºÁÚòµÚ òÜ·òÚÀò†·ò©ÞºÊÔ º¤‚òË©òµÚ ò×ÐòÝкÓ⁄òµÃ Œ· ºƒ‹óÕÚŒ‡©, òÁ‹òÜ’ò×к¥… òÞÃóÕÞ òÅÌóÔÃóÊ‚òݤòÖ·òÛ  Œ•‚ºƒ‹Œ‡© òÁ‹òÜ’ò×ÐòÛ  óÕÚºÓÞòݤòÖ·òµÚ òÁ‹òµ·º¥… òÙ®Œ†®óÕÚºÊÔ(ò¡®ò©ÕóÕÚºÊÔ,interface)óÖÉòÞúÓ⁄òµÃ ò©ÞŒ‡¦óÕÞºË⁄(òÁ‹òÜ’ò×ÐòÛ  óÕÚºÓÞòݤòÖ· òÁ‹òµ·òµÚ interfaceº¥… ò©ÞŒ‡¦óÕÞºË⁄). 
  45. <br>
  46. <br>Among the many software packages provided by the operating system are the C compiler and various text editors. The principal text editor on the UNIX system is called vi. Some systems, such as Borland C++, integrate the text editor and the compiler. 
  47. <br>
  48. <br>òÜ·òÚÀò†·ò©Þ(Operating system)òÙРòµÚóÕ·òÃÞ ò©ÞŒ‡¦ºÐÚòÖ·ò§ ºÊÔ º§Îòµ  òÅÌóÔÃóÊ‚òݤòÖ· óÌ’óÁ⁄ò§ ºÓ⁄ ò⁄ÑòÙкÊÔ C compiler òÛ  ºË⁄òÖÑóÕÞ º‹‚òÃÞó΂ò§ÑŒ‚®(text editor)Œ®  ò×ȺË⁄. UNIX systemòÙÐòÃÞòµÚ ò£…ºÐÞ º‹‚òÃÞ ó΂ò§ÑŒ‚®ºÊÔ vi ºµ… º¶Èºƒ®ºË⁄. Borland C++ Œ‡… Œ®Ûòµ  òÖ·ºÖ⁄ òËÞòÊ⁄óÄÞºÓ⁄òµ  º‹‚òÃÞó΂ò§ÑŒ‚®òÛ  compilerº¥… óŦóÕ’óÕÚŒ‡© ò×ȺË⁄. 
  49. <br>
  50. <br>We assume that the reader is able to use some text editor to create files containing C code. Such files are called source files, and they are compiled on most UNIX system with the cc command, which invokes the C compiler. Because the cc command invokes the compiler, the name of the command is also the name of the compiler. Thus, C compiler and cc compiler are used interchangeably. Roughly speaking, a compiler translates source code to object code that is executable. 
  51. <br>
  52. <br>òÜ®ºƒ‹ºÊÔ Œ® ò©ÕóÕÞºË⁄. ºÏÄò×кÓ⁄òµ· C codeº¥… óÏ‹óÕ¤óÕÚŒ‡© ò×ȺÊÔ óÌÌòµ…òµÃ òµòÖóÕÚŒ‚® òÞÃóÕÞ òÖ·ºÖ⁄ º‹‚òÃÞ ó΂ò§ÑŒ‚®º¥… òÁ‹òÜ’óÕ© òÈÚ ò×ȺË⁄ºÊÔ Œ†ÂòµÃ. Œ•‚º÷‹óÕÞ óÌÌòµ…ºÓ⁄òµÃ sourceóÌÌòµ… òµ·ºµ… óÕÚŒ‡©, Œ•‚ºÓ⁄òµ  ºÌ º¶ º¶ÃòµÚ UNIX systemòÙÐòÃÞcc ºµ…ºÊÔ º“ĺ©„òÞ…º¡Þ compile ºÐÚòÖ·ò§ÃºË⁄. cc ºµ…ºÊÔ º“ĺ©„òµ  C compilerº¥… º¶Èº÷‹ºÓ⁄òµ‚ºË⁄. cc ºµ…ºÊÔ º“ĺ©„òÖ·Œ®  ò»·óÌÌòµ…º÷‹º¥… º¶Èº÷‹ºÓ⁄òµ·Œ‚® ºÕ̺‹‚òÙÐ, º“ĺ©„òÖ·òµÚ òµ·ºƒÃòµ  ºÚÐóÕÞ ò»·óÌÌòµ…º÷‹òµÚ òµ·ºƒÃòµ·ºË⁄. Œ•‚º÷‹ºfl º¡Þ, C compiler òÛ  cc compiler ºÊÔ Œ¦ÐóÛÚóÕÚòÙ‹(Œ®Ûòµ  òµÚºfl‚º¡Þ) òÁ‹òÜ’ ºÐÚòÖ· ò¡ÌºË⁄. Œ–®ò„©Œ†Ì º§ÐóÕÚò×к’·, ò»·óÌÌòµ…º÷‹ºÊÔ source codeº¥… òË⁄óÖÉóÕ© òÈÚ ò×ȺÊÔobject codeº¡Þ º‡ óÛÚòËÞò…Þò£…ºÊÔ Œ†Âòµ·ºË⁄. 
  53. <br>
  54. <br>On UNIX systems, this compiled code is automatically created in a file named a.out. 
  55. <br>On MS-DOS systems, this compiled code is automatically created in a file with the same name as the .c file, but with the .exe extension replacing the .c extension. At the end of this chapter, in Section 1.10, í ÞOperating System Considerations,í µ on page 53, we present in detail the steps necessary to edit, compile, and execute a program. 
  56. <br>
  57. <br>UNIX systemòÙÐòÃÞºÊÔ òµ· ò»·óÌÌòµ…ºÐÞ ò‰ÔºÓÞŒ® a.outòµ·ºµ…ºÊÔ óÌÌòµ… òµ·ºƒÃ òÕÈòÙРò×кÏÛò©ÀòÞ…º¡Þ º§ÌºÓ⁄òÖ·ò§ÃºË⁄.(ò»·óÌÌòµ… óÕÚº’· Œ•‚ óÌÌòµ… òµ·ºƒÃòµ· a.outòµ· ºÐÞºË⁄.) 
  58. <br>MS-DOS systemòÙÐòÃÞºÊÔ òµ·º©ÇŒ†Ì compile ºÐÞ ò‰ÔºÓÞŒ®  .c óÌÌòµ…Œ‡… Œ®Ûòµ  òµ·ºƒÃòÞ…º¡Þ ò®‰ò¡®ºÐÚòÖ· ò§ÃºË⁄. ºË¤ò§  .c óÛÕò×¥ò×ÐŒ®  .exe óÛÕò×¥ò×к¡Þ Œ¦Ðò†·ºÐÚº’·òÃÞ. (ºÏÃòÊ⁄òÙÐòÃÞºÊÔ poem.c ºµ…ºÊÔ òÅÌòÊ⁄ ò‰ÔºÓÞº¥… ò»·óÌÌòµ… óÕÚº’· poem.exe ºµ…ºÊÔ òË⁄óÖÉ óÌÌòµ…òµ· º§ÌºÓ⁄òÖ·ò§ ºÊԺͮ ºÒ⁄òÙРò×ȺÊÔ óÛÕò×¥ò×Ð(.c -> .exeº¡Þ)º§Ì º®Ôº Ìº’·òÃÞ òÕ×òµÚ í Úpoemí Ûòµ·ºµ…ºÊÔ òµ·ºƒÃòµ  Œ•‚ºÌ º¡Þ òÞ©ò§  ºÐÞºË⁄ºÊÔ Œ†Âòµ·ºË⁄.) 
  59. <br>òµ· ò–ÕóîòµÚ º§Èò§ º§É º¶ º¶Ã, Section 1.10òÕÈòµÚ, 53pageòÙРò×ȺÊÔí µOperating System Considerationsí µ(òÜ·òÚÀò†·ò©ÞòµÚ Œ‡©ò®®)òÙÐòÃÞ òÜ®ºƒ‹ºÊÔ óÔú¡ÞŒ•‚º×¤òµÚ ó΂ò§Ñ, ò»·óÌÌòµ…, Œ•‚ºƒ‹Œ‡© òË⁄óÖÉóÕÚŒ‚®òÞÃóÕ· óÕÃòÜÔóÕÞ òº¶ ò©Àòµ‚ Œ‡…ò©ÕºÓ⁄òµÃ òÅÌŒ®ÞóÕÞºË⁄. 
  60. <br>
  61. <br>1.2 Program Output 
  62. <br>
  63. <br>Programs must communicate to be useful. Our first example is a program that prints on the screen the phrase í Þfrom sea to shining C.í µ The complete program is 
  64. <br>
  65. <br>óÔú¡ÞŒ•‚º×¤ºÓ⁄òµ  òÞ©òÜ’óÕ¤òµÃ(òͤº¤„Œ‚®)òÞÃóÕ· ò©ÃºË‹(communicate) ºÐÚòÖ·òÕ… óÕÞºË⁄. òÜ®ºƒ‹òµÚ ò†«º†Èò§‚ òÚȺÊÔ òÊ⁄óÀ‹ºƒ®òÙРí Þfrom sea to shining C.í µ ºµ…ºÊÔ º‹‚Œ¦‹º¥… óÔúƒ®óÊ‚óÕÚºÊÔ óÔú¡ÞŒ•‚º×¤òµ·ºË⁄. òÛÃòÖºÐÞ óÔú¡ÞŒ•‚º×¤òµ  In file sea.c òÙРò×ȺË⁄. 
  66. <br>
  67. <br>In file sea.c 
  68. <br>
  69. <br>#include 
  70. <br>
  71. <br>int main(void) 
  72. <br>{ 
  73. <br>printf(í Þfrom sea to shining C\ní µ); 
  74. <br>return 0; 
  75. <br>} 
  76. <br>
  77. <br>Using a text editor, we type this into a file whose name ends in .c. The choice of a file name should be mnemonic. Let us suppose the program has been written in the file sea.c. To compile the program, we give the command 
  78. <br>
  79. <br>º‹‚òÃÞ ó΂ò§ÑŒ‚®(text editor)º¥… òÁ‹òÜ’óÕÚòÙ‹, òÜ®ºƒ‹ºÊÔ Œ•‚ óÌÌòµ…òµÚ òµ·ºƒÃòµÚ ºÀµòµ· .c òµ‚ óÌÌòµ… òÕÈòÙРòµ·Œ†Â(òÞÃòÙРò×ȺÊÔ source code)òµÃ òͤ ºÃ£ºÊÔºË⁄. óÌÌòµ… òµ·ºƒÃòµÚ òéóµòµ  Œ‚®òÖ¦óÕÚŒ‚® òÉ‹òÜ· Œ†ÂòÞ…º¡Þ óÕÞºË⁄. sea.c ºµ…ºÊÔ óÌÌòµ… òÕÈòÙРóÔú¡ÞŒ•‚º×¤òµ· òÓ®òÙ‹ò¡ÌºË⁄Œ‡© Œ® ò©ÕóÕ· º‡·ò×Ð. Œ•‚ óÔú¡ÞŒ•‚º×¤òµÃ ò»·óÌÌòµ… óÕÚŒ‚® òÞÃóÕ· òÜ®ºƒ‹ºÊÔ º“ĺ©„òµÃ ò⁄ ºË⁄. 
  80. <br>
  81. <br>cc sea.c 
  82. <br>
  83. <br>If there are no errors in the code, the executable file a.out is created by this command. 
  84. <br>Now the command 
  85. <br>
  86. <br>º§ÌòÕ‰ ò‰ÔºÓÞ òÕÈòÙРòÕú‹·º÷® òÙк÷‹Œ®  òÙźË⁄º’·, òµ· º“ĺ©„(òÞÃòÙРòÓ· cc sea.c)òÙРòµÚóÕ· òË⁄óÖÉ Œ® ºÊ¥óÕÞ óÌÌòµ… a.outòµ· º§ÌºÓ⁄òÖ· ò§ÃºË⁄. 
  87. <br>òµ·ò©Þ º“ĺ©„ a.out òµ  
  88. <br>
  89. <br>a. out 
  90. <br>
  91. <br>executes the program and prints on the screen 
  92. <br>óÔú¡ÞŒ•‚º×¤òµÃ òË⁄óÖÉóÕÚŒ‡©(ºË⁄òµÌ ºÁ·òÜ’òµÃ) òÊ⁄óÀ‹ºƒ® òÞÃòÙРóÔúƒ®óÊ‚ óÕÞºË⁄. 
  93. <br>
  94. <br>from sea to shining C 
  95. <br>
  96. <br>Dissection of the sea Program (óÔú¡ÞŒ•‚º×¤ seaòµÚ óÕ·º¶ ) 
  97. <br>
  98. <br>#include 
  99. <br>
  100. <br>A preprocessor is built into the C compiler. When the command to compile a program is given, the code is first preprocessed and then compiled. Lines that begin with a # communicate with the preprocessed. This #include line causes the preprocessor to include a copy of the header file at this point in the code. 
  101. <br>This header file is provided by the C system. The angle brackets around indicate that the file is to be found in the usual place, which is system-dependent. We have included this file because it contains information about the printf() function. 
  102. <br>
  103. <br>Preprocessor(ò©Ãò†Úºƒ‹ ò×¥ò„Ú, ºfl‚ºƒ‹ º¶ÃòõóÕÚºÊÔ ò×¥ò„Ú: ò© òµÚ º†ÈòÙ›òÙÐòÃÞºÊÔ preprocessorº¥… Œ•‚ºÂ¥ Œ‡©òÞ© º“ÄòÁ‹óÛÔ óÕ·òÃÞ òÁ‹òÜ’óÕ© Œ†Âò×ĺËȺË⁄. í Úò©Ãò†Úºƒ‹ ò×¥ò„Úí Ûºµ…ºÊÔ ºË¤òÖ·º‡·ºË⁄ preprocessorºµ…ºÊÔ ºË¤òÖ·Œ®  ºÍÔ ºÁ«ºË⁄Œ‡© òµŒ®ÀóÕ’ºËȺË⁄. òÕ×òÞ…º¡ÞºÏຓǠŒ®Þ ò©ÕºÏúÊÔ Œ‡©òÞ© º“ÄòÁ‹óÛÔ óÕ·òÃÞ òÁ‹òÜ’óÕÚºÊÔ ºË¤òÖ·ºÓ⁄òµ· ò×ÈòµÃ Œ†ÀºËȺË⁄.)ºÊÔ C ò»·óÌÌòµ…º÷‹òÙРòµÚóÕ·(C ò»·óÌÌòµ…º÷‹º¥… òͤòÃÞ) ò¡®ºƒ‰ºÐÚòÖ· ò¡ÌºË⁄(º§ÌºÓ⁄òÖ· ò¡ÌºË⁄, is built into). 
  104. <br>#Œ‡… óÕ¤Œ»Ú òËÞò×ÑóÕÚºÊÔ ò⁄Ã(º‹‚ò×¥)ºÓ⁄òµ  ºfl‚ºƒ‹ º¶ÃòõºÐÚòÖ·òÃÞ(ò©Ãò†Úºƒ‹ ºÐÚòÖ·òÃÞ,preprocessed) ò©ÃºË‹(òµÚòÁ‹òÅÌóŦ, óŦòË©)ºÐÞºË⁄. 
  105. <br>òµ· #include ºµ…òµ‚òµ  (preprocessorº¥… òµ·òÜ’óÕ·) ò‰ÔºÓÞ òÕÈòµÚ òµ· º¶ º¶Ã, òƒÉ óÙ⁄ºÍÔ óÌÌòµ…òµ‚ òµÚ óÕÚºÁÚòµÚ ò„·óÔ…(º‡¦ò©Þ,a copy)º¥… º¶Èº÷‹ºÓ⁄òµ·Œ‚®(to include)òÞÃóÕ· preprocessorº¥… òµ…òÞ…óÁ¤ºË⁄. 
  106. <br>(Œ®Þòµ‚ò©Àòµ‚ óÕ·òÃ⁄: # include ºµ…òµ‚òµ  ºµ…ºÊÔ óÙ⁄ºÍÔ óÌÌòµ…òµÃ º¶Èº÷‹ ºÓ⁄òµ·ºÊԺͮ(º‡¦òÁ‹ óÕÚºÊԺͮ) Œ•‚º©ÇŒ†Ì óÕÚŒ‚® òÞÃóÕ·òÃÞ ºfl‚ºƒ‹ º¶ÃòõóÕÚºÊÔ ò×¥ò„Úòµ‚ preprocessorº¥… òµ…òÞ…óÁ¤ºË⁄ºÊÔ(causes) óÚ„òµ  òÁ‹òÜ’óÕÞºË⁄ºÊÔ òµ·òÕ…Œ‚® ò×ĺËȺË⁄. Œ•‚º÷… òÛÞ óÙ⁄ºÍÔóÌÌòµ…òµÃ º¶Èº÷‹ ºÓ⁄òÙ‹òÕ… óÕÚºÁÚòÜÔ? ò»·óÌÌòµ…º÷‹Œ®  òµ‚Œ®ÃòµÚ source codeº¥… Œ‚®Œ‡ÃòÖ·º¡Þ º®ÔŒ¬‚òÖ·ò£…òÖ· 0Œ‡… 1,(ò©Ãº¥ÚŒ®  óµÐº¥·ºÂРóµÐº¥·ò§  òÕʺÊкÂÐ)º®ÖòÙРòÕÌ òÈÚ òÙźÊÔmachine òÙÐŒ†Ì òµ‚ò˵óÕÚºÏú¡µ óÕ·ò£…ºÊÔ Œ†Âòµ·ºµ…ºÊÔ Œ†Âòµ·ºµ…Œ‡© òµŒ®À óÕ© ºÕÌ Œ•‚ ò⁄ÑŒ®ÃòÙРòÖ·ºÖ©óÕÞ òÙ®Œ†® Œ‡©ºƒ‹Œ®  ò×ÈòÖ·òÕ… óÕÚŒ†©ò§ òÜÔ? óÚ„òµ  òÕÃò£… Œ‚®º‡‚òµ· ºÐÚºÊÔ óÕ¤òÈÚºÓ⁄òµ· ò×ÈòÖ·òÕ… óÕÚò§  òÕÊòµÃŒ„ÌòÜÔ? 0Œ‡… 1òÙРŒ® Œ„µŒ–®ºÁÚ óÚ„òµ  Œ•‚Œ†ÂºÓ⁄òÙРò©ÑŒ•…óÕ© òÈÚ ò×ȺÊÔ Œ‚®º‡‚ò©Àòµ‚ óÕ¤òÈÚºÓ⁄ º§Ðòµ·ò£©. º‹…º¡© ò¡®Œ‚È òµÑòÜ’ºÐÞ óÕ¤òÈÚºÓ⁄ºÏàò×ÈŒ†©ò§ òÜÔ. º›Ð Œ…› òµ·º÷‹óÕÞ Œ†Âòµ· óÙ⁄ºÍÔóÌÌòµ…òµÚ ò©ÕòµÚºÊÔ òÕúËÈŒ†©ò§ º§Ì òÛÞ óÙ⁄ºÍÔóÌÌòµ…òµÃ º¶Èº÷‹ºÓ⁄òÙ‹òÕ…º§Ì óÕÚºÊÔŒ® òÙРºÌ óÕÞ Œ¶ÀŒ‚Èòƒµ ò©ÕºÏÃŒ®  óÒ ºƒ‹ºÊÔ ºÍ®òÙкÊÔ ºÏÃòÝ òµ· ºÐ© Œ†Â Œ®ÛòʦºËȺË⁄.) 
  107. <br>
  108. <br>int main(void) 
  109. <br>
  110. <br>This is the first line of the function definition for main(). (We write parentheses after the name main to remind the reader that main() is a function.) The two words int and void are keywords, also called reserved words. They have special meaning to the compiler. In Section 2.4, í ÞKeywords,í µ on page77, we will see that there are 32 keywords in C, including int and void. 
  111. <br>
  112. <br>òµ·Œ†Âòµ  main()óÕ¤òÈÚº¥… òÞÃóÕÞ óÕ¤òÈÚò©ÕòµÚòµÚ ò†«º†Èò§‚ ºµ…òµ‚òµ·ºË⁄. (òÜ®ºƒ‹ºÊÔ main()òµ· óÕ¤òÈÚºµ…ºÊÔ Œ†ÂòµÃ òµ‰ºÊÔ òµ·òÙÐŒ†Ì òÂÀŒ‚®òËÞóÁ⁄Œ‚® òÞÃóÕ· mainòµ·ºµ…ºÊÔ òµ·ºƒÃ ºÒ⁄òÙРŒ·ÃóÚ‚(parenthesis)º¥… òÓ·ºË⁄.) ºÑРºË¤òÖ· int òÛ  voidºÊÔ keywords(òµ·Œ†Â ºÚÐóÕÞ Œ‡©òÞ©º“ÄòÁ‹º¡Þ òÓ®Œ†©òʦºËȺË⁄.)òµ·ºË⁄. ºÚÐóÕÞ òÚÈòÕ‰ºÐÞ(óÝÙºÁ©òµÃ òÞÃóÕ· ºÖ…òÖ· ºÅÓòµ , reserved) ºË¤òÖ·ºÓ⁄òµ·ºµ…Œ‡©ºÏຶ º¥‚ºË⁄. Œ•‚ºÓ⁄òµ  ò»·óÌÌòµ…º÷‹òÙÐŒ†Ì óÊ„º‡ÃóÕÞ òµÚºfl‚º¥… ò§ ºË̺Ë⁄. 77pageòÙРIn Section 2.4, í Þkeywords,í µ òÙÐòÃÞ, òÜ®ºƒ‹ºÊÔ C òÕÈòÙÐòÃÞòµÚ 32Œ®ÞòµÚ keywordsº¥… º‡… Œ†Âòµ·ºË⁄, int òÛ  void º¥… óÏ‹óÕ¤óÕÚòÙ‹. 
  113. <br>
  114. <br>int main(void) 
  115. <br>{ 
  116. <br>.... 
  117. <br>
  118. <br>Every program has function named main(). Program execution always starts with this function. The top line should be read as í Þmain() is a function that takes no arguments and return an int value.í µ 
  119. <br>
  120. <br>º“¤ºÓ© óÔú¡ÞŒ•‚º×¤òµ  main()òµ·ºµ…ºÊÔ òµ·ºƒÃòµÚ óÕ¤òÈÚº¥… Œ®ÖºÊÔºË⁄. óÔú¡ÞŒ•‚º×¤òµÚ òË⁄óÖÉòµ  óÕ›òÂÀ òµ· óÕ¤òÈÚòÛ  óÕ¤Œ»Ú òËÞò×ÑóÕÞºË⁄. ò©Þòµ… òÞÃòµÚ ºµ…òµ‚òµ  í Þmain()òµ  òÖ·ºÖ⁄ ºÏĺƒ‰º‡ òÈÚ(arguments) ºÓ⁄ºÏàò•¤óÕÚò§  òÕÊòÞ…º’® int valueº¥… ºÐÚºÏ̺ƒ®ºË⁄í µ ºµ…Œ‡© òµ‰óÚ ò©‚òÕ… óÕÞºË⁄. 
  121. <br>
  122. <br>Here, the keyword int tells the compiler that this function returns a value of type int. The word int stands for integer, but the word integer itself cannot be used. The parentheses following main indicate to the compiler that main is a function. 
  123. <br>
  124. <br>òÙ‹Œ‚®, óÁ⁄òÝ̺ÓÞ int ºÊÔ ò»·óÌÌòµ…º÷‹òÙÐŒ†Ì òµ· óÕ¤òÈÚºÊÔ int óÚÕ(int type)òµÚ Œ®ÒòµÃ ºÐÚºÏ̺ƒ®ºË⁄Œ‡© òÖÚŒ‚®óÕÞºË⁄. int ºµ…ºÊÔ ºË¤òÖ·ºÊÔ ò©ÕòÈÚ(integer)º¥… òµÚºfl‚óÕÚò§ º§Ì(integer òµÚ òÕ‰ò×Ðòµ·ò§ º§Ì), integerºµ…ºÊÔ ºË¤òÖ·ºÊÔ Œ•‚ òÊ⁄òÊ⁄º¡Þ òÁ‹òÜ’ºÐÚòÖ· ò§È òÈÚ òÙźË⁄. main óÕ¤òÈÚ ºÒ⁄òÙÐòÚ⁄ºÊÔ Œ·ÃóÚ‚() ºÊÔ ò»·óÌÌòµ…º÷‹òÙÐŒ†Ì mainòµ  óÕ¤òÈÚºµ…ºÊÔ Œ†ÂòµÃ Œ® ºƒ‹óÁ¤ºË⁄. 
  125. <br>
  126. <br>This idea is confusing at first because what you see following main is (void), but only the parentheses () constitute an operator telling the compiler that main is a function. The keyword void indicates to the compiler that this function takes no arguments. When we write about functions such as main() and printf(), we usually follow the name in print with parentheses. This indicates to the reader that we are discussing a function. (Many programming books follow this practice.) 
  127. <br>
  128. <br>òµ· óÚÕóÂÞ(òÛ‚Œ· ,idea)ºÊÔ mainºÒ⁄òÙРºÔ®º¥·ºÊÔ (void) º¥… ºË„òË©òµ· º‡·ºÊÔ òµ·òÞ©º¡Þ ò†ÚòµÌòÙРóÚ…º× òÊ⁄º÷‰ºË⁄. 
  129. <br>óÕÚò§ º§Ì ºË¤ò§  Œ·ÃóÚ‚ºÊÔ mainòµ  óÕ¤òÈÚºµ…Œ‡© ò»·óÌÌòµ…º÷‹òÙÐŒ†Ì òÖÚŒ‚®óÕ·ò£…ºÊÔ òÙ®òÁ®ò×Ð(operator)º¥… Œ¦‹òÖóÕÞºË⁄. óÁ⁄òÝ̺ÓÞ void ºÊÔ, òÖ·ºÖ©óÕÞ ºÏĺƒ‰º‡ òÈÚ(arguments) ºÓ⁄ºÏàò•¤óÕÚò§  òÕʺÊÔ òµ· óÕ¤òÈÚº¥… ò»·óÌÌòµ…º÷‹òÙÐŒ†Ì òµ‚ò˵ò…  óÕÞºË⁄. (Œ•‚º÷‹ºËÈŒ„Ì int main(void)òÙÐòÃÞ voidºÊÔ òµ· óÕ¤òÈÚŒ®  òÖ·ºÖ©óÕÞ ºÏĺƒ‰º‡ òÈÚºÏàò•¤óÕÚò§  òÕʺÊÔºË⁄ºÊÔ Œ†ÂòµÃ Œ® ºƒ‹óÁ¤ºË⁄ºÊÔ Œ†Âòµ·ºË⁄. òÜ®ºƒ‹Œ®  main() Œ‡… printf()òÛ  Œ®Ûòµ  óÕ¤òÈÚºÓ⁄òÙРºÌ óÕ· òÓ‚ ºÕÌ, òÜ®ºƒ‹ºÊÔ òµ…º®Úò©ÀòÞ…º¡Þ Œ·ÃóÚ‚òÛ  óÕ¤Œ»Ú òÓ®òµ‚ òµ·ºƒÃºÓ⁄òµÃ ºÔ®º¥‚ºË⁄. (òµ· º‹‚ò×¥òµ  òÕÃò£… ò׋º®ÌºÊÔ º‹‚ò×¥òµ‚ºÍ® Œ•‚º÷‹ºËÈŒ„Ì óÕ¤òÈÚºÓ⁄òµÃ òÓ‚ ºÕÌ main() , printf() òµ·º÷® ò˵òÞ…º¡Þ Œ·ÃóÚ‚òÛ  óÕ¤Œ»Ú òÓ·ºË⁄ºÊÔ ºÁ·òÜ’ò×ĺËȺË⁄.) òµ·Œ†Âòµ  ºÏÄò×кÓ⁄òÙÐŒ†Ì òÜ®ºƒ‹Œ®  óÕ¤òÈÚòÙРºÌ óÕ· ºÄ…òµÚóÕÚŒ‡© ò×ȺË⁄ºÊÔ Œ†ÂòµÃ Œ® ºƒ‹óÁ¤ºË⁄. 
  130. <br>(º§Îòµ  óÔú¡ÞŒ•‚º×Úº®Í ò–ĺÓ⁄òµ· òµ·º÷‹óÕÞ òʦŒ· (Œ· º¡ )òµÃ ºÔ®º¥‚ºË⁄.) 
  131. <br>
  132. <br>{ 
  133. <br>
  134. <br>Braces surround the body of a function definition. They are also used to group statement together. 
  135. <br>ò⁄ÑŒ·ÃóÚ‚ºÊÔ óÕ¤òÈÚò©ÕòµÚòµÚ º“‚òµÃ º‹¶ºÊÔºË⁄. Œ•‚ºÓ⁄òµ  ºÚÐóÕÞ º‹‚ò×¥ Œ•‚º£„òÞ…º¡Þ óÕ¤Œ»Ú òÁ‹òÜ’ºÐÚòÖ·ò§ÃºË⁄. 
  136. <br>
  137. <br>printf() 
  138. <br>
  139. <br>The C system contains a standard library of functions that can be used in programs. 
  140. <br>This is a function from the library that prints on the screen. We included the header file stdio.h because it provides certain information to the compiler about the function printf(). 
  141. <br>
  142. <br>C systemòµ  óÔú¡ÞŒ•‚º×¤ºÓ⁄òµ· òÁ‹òÜ’ºÐÚòÖ·ò§È òÈÚ ò×ȺÊÔ óÕ¤òÈÚºÓ⁄òµÚ óÑÞò⁄  ºµ…òµ·º‚̺÷‹ºƒ‹º¥… óÏ‹óÕ¤óÕÞºË⁄. òµ· óÕ¤òÈÚºÊÔ òÊ⁄óÀ‹ºƒ® òÞÃòÙРóÔúƒ®óÊ‚ ºÐÚòÖ·ò§ ºÊÔ ºµ…òµ·º‚̺÷‹ºƒ‹ óÕ¤òÈÚòµ·ºË⁄. òÜ®ºƒ‹ºÊÔ óÙ⁄ºÍÔóÌÌòµ… stdio.hº¥… óÏ‹óÕ¤òËÞò…®ºË⁄. òµ·òÞ©ºÊÔ Œ•‚Œ†Âòµ  printf()óÕ¤òÈÚòÙРºÌ óÕÞ óÛÕòË⁄óÕÞ ò©Õº‡·º¥… ò»·óÌÌòµ…º÷‹òÙÐŒ†Ì ò©ÞŒ‡¦óÕÚŒ‚® ºÕ̺‹‚òÙÐ. 
  143. <br>
  144. <br>í Þfrom sea to shining C\ní µ 
  145. <br>
  146. <br>A string constant in C is a series of characters surrounded by double quotes. This string is an argument to the function printf(), and it controls what gets printed. The two characters \n at the end of the string(read backslash n) represent a single character called newline. It is a nonprinting character. It advances the cursor on the screen to the beginning of the next line. 
  147. <br>
  148. <br>C òÕÈòÙÐòÃÞòµÚ º‹‚ò×ÐòÙ· òÂÀòÈÚ(string constant)ºÊÔ ºÔ®òÚ·óÑÞòÙРòµÚóÕ· ºÑÚº÷‹òË‚òÙ‹ò§Ã º‹‚ò×кÓ⁄òµÚ óÕÞ òËÞºƒ‹òƒÈºË⁄. 
  149. <br>òµ· º‹‚ò×ÐòÙ·òµ  printf() óÕ¤òÈÚòµÚ óÕÞ ºÏĺƒ‰º‡ òÈÚ(Œ‡©ò©Õº‡ òÈÚ, argument)òµ·ºË⁄. Œ•‚ºƒ‹Œ‡© Œ•‚Œ†Âòµ  º‹·òÙÇòµ· óÔúƒ®óÊ‚ ºÐÚòÖ·ò§Èò§  ò‰ÚóÊ‚º¡⁄ óÕÞºË⁄. º‹‚ò×ÐòÙ·òµÚ ºÀµòÙРò×ȺÊÔ ºÑРº‹‚ò×кÓ⁄ \n (í Þbackslash ní µ òµ·ºµ…Œ‡© òµ‰ºÊÔºË⁄)òµ  òÂȺ¡ÞòÜ· ò⁄Ã(newline)òµ·ºµ… º¶Èºƒ‹ºÊÔ óÕÚºÁÚòµÚ ºÏÄò×ÐòÖòµÃ Œ® ò§Ã(òÈÞòÈÚóÕÞ,single) º‹‚ò×к¥… ºÁÚó ºÁ‚ºË⁄. Œ•‚Œ†Âòµ  ò®Íó×Èò§  òÕʺÊÔ º‹‚ò×Ðòµ·ºË⁄. Œ•‚Œ†Âòµ  òÊ⁄óÀ‹ºƒ® òÞÃòµÚ ò»⁄òÃÞº¥… ºË⁄òµÌ ºµ…òµ‚òµÚ òËÞò×Ѻ¶ º¶ÃòÙРò§Ãº‡·(òÞÃò„Ú)òËÞóÁ¤ºË⁄. 
  150. <br>
  151. <br>Printf(í Þfrom sea to shining C\ní µ); 
  152. <br>
  153. <br>This is statement. Many statements in C end with a semicolon. 
  154. <br>òµ·Œ†Âòµ  ò§ÃòÈ©òµ·ºË⁄(º‹‚ò×¥òµ·ºË⁄). CòÕÈòÙÐòÃÞ º§Îòµ  º‹‚ò×¥(ò§ÃòÈ©, statements)ºÓ⁄òµÚ ºÀµòµ  òºfl‚ò‰Þº¡©Œ‡… óÕ¤Œ»ÚóÕÞºË⁄. (C òÖ‚òÖ·òÙÐòÃÞºÊÔ º‹‚ò×¥òµÚ ºÀµòÙÔ òºfl‚ò‰Þº¡© semicolon òµÃ òÓ·ºË⁄ºÊÔ òÖÚŒ‚®ò×ĺËȺË⁄.) 
  155. <br>
  156. <br>return 0; 
  157. <br>
  158. <br>This is a return statement. It causes the value zero to be returned to the operating system, which in turn may use the value in some way, but is not required to do so. 
  159. <br>(See Section 12.7, í ÞReturning the Status,í µ on page 579, for further discussion.) 
  160. <br>
  161. <br>òµ·Œ†Âòµ  ºƒ‹ó÷ º‹‚òµ·ºË⁄. òµ·Œ†Âòµ  òÜ·òÚÀò†·ò©ÞòÙÐŒ†Ì òÚÀòµÚ Œ®ÒòµÃ ºÐÚºÏ̺©⁄ º®ÝºÊÔ òÝÐòµ‚òµ· ºÐÞºË⁄. òÜ·òÚÀò†·ò©ÞºÊÔ òÖ·ºÖ⁄ Œ†‰º¡Þ(Œ†‰òÜ®, º®’º†Õ)òÙРò×ÈòÖ·òÃÞºÊÔ ºÏ̺©⁄ º®ÝºÊÔ Œ®Òòµ· òÁ‹òÜ’ºÐÚòÖ· ò§È òÈÚºÏàò×Èò§ º§Ì, óÕÚò§ º§Ì Œ•‚º©ÇŒ†Ì óÕÚŒ‚®òÞÃóÕ· òÜÔŒ¦‹ºÐÚòÖ·ò§ ò§ ºÊÔ òÕʺÊÔºË⁄. (Œ®ÒòµÃ ºÏ̺©⁄ º®ÝòµÃ òÈÚºÏàòÕúËРòÈÚºÏàò×ȺË⁄.) 
  162. <br>
  163. <br>Our use of this return statement keeps the compiler happy. If we do not use it, the compiler will complain.(See exercise 4, on page 60.) One of the principal rules of programming is í Þkeep your compiler happy.í µ 
  164. <br>
  165. <br>òµ·º÷‹óÕÞ ºƒ‹ó÷ º‹‚òµÚ òÓ®ò×ÃòÂȺÊÔ ò»·óÌÌòµ…º÷‹º¥… óÖɺ‡¦óÕÚŒ†Ì òÞ©ò§ óÕ·ò⁄ ºË⁄. º§ÌòÕ‰ òÜ®ºƒ‹Œ®  òµ·Œ†ÂòµÃ òÁ‹òÜ’óÕÚò§  òÕʺÊÔºË⁄º’·, ò»·óÌÌòµ…º÷‹ºÊÔ º¶ÈóÏÉòµÃ óÕ© Œ†Âòµ·ºË⁄. óÔú¡ÞŒ•‚º×Úº®ÍòµÚ Œ•…º‡‚ò©Àòµ‚ º†Õò„Ûòµ  í Þò»·óÌÌòµ…º÷‹º¥… óÖɺ‡¦óÕÚŒ†Ì óÕ·ºµ….í µ òµ·ºË⁄. 
  166. <br>
  167. <br>} 
  168. <br>
  169. <br>The right brace matches the left brace above, ending the function definition for main(). 
  170. <br>òÚ⁄º¥‚ò“‰ ò⁄ÑŒ·ÃóÚ‚ºÊÔ òÕ×òÙРò×ȺÍÚ òÛ…ò“‰òµÚ ò⁄ÑŒ·ÃóÚ‚òÛ  º§⁄ò„ÚºÐÚŒ‡©, main()òµÃ òÞÃóÕÞ óÕ¤òÈÚò©ÕòµÚòµÚ ò¢ÄŒ†®òµ·ºË⁄. 
  171. <br>
  172. <br>
  173. <br>+ + + + + + + 
  174. <br>
  175. <br>The function printf() acts to print continuously across the screen. It moves the cursor to the start of a new line when a newline character is read. The screen is a two-dimensional display that prints from left to right and top to bottom. To be readable, output must appear properly spaced on the screen. 
  176. <br>We can rewrite our first program as follows: 
  177. <br>
  178. <br>óÕ¤òÈÚ printf()ºÊÔ òÊ⁄óÀ‹ºƒ®òµÃ ò§ òÅÍò©ÀòÞ…º¡Þ Œ® º¡Þò§ º¥·ºÊÔ óÔúƒ®óÊ‚º¥… óÕÚŒ‚® òÞÃóÕ· òË⁄óÖÉóÕÞºË⁄. Œ•‚Œ†Âòµ  newline(\n) º‹‚ò×ÐŒ®  òµ‰óÚ  ò¡ÌòµÃ ºÕÌ òÂȺ¡ÞòÜ· ò⁄ÃòµÚ òËÞò×ÑòÙРò»⁄òÃÞº¥… Œ®ÖºË⁄ ºÅÓºÊÔºË⁄. òÊ⁄óÀ‹ºƒ®òµ  2ò®¤òÝÐòµÚ, Œ•‚º÷‹ºËÈŒ„Ì òÛ…ò“‰òÙÐòÃÞº¶ óî òÚ⁄º¥‚ò“‰òÞ…º¡Þ Œ•‚ºƒ‹Œ‡© òÞÃòÙÐòÃÞº¶ óî òÕú×Úº¡Þ óÔúƒ®óÊ‚óÕÚºÊÔ dispalyòµ·ºË⁄. òµ‰òµÃ òÈÚ ò×ÈŒ†Ì óÕÚŒ‚® òÞÃóÕ·, ò¶Þº©¥(output)òµ  òÊ⁄óÀ‹ºƒ® òÞÃòÙРò©Àò©ÈóÕÞ Œ‡¦Œ®ÃòµÃ ºÁÚó ºÁ·òÖ·òÕ… óÕÞºË⁄. 
  179. <br>òÜ®ºƒ‹ºÊÔ òÜ®ºƒ‹òµÚ ò†«º†Èò§‚ óÔú¡ÞŒ•‚º×¤òµÃ ºË⁄òµÌŒ‡… Œ®Ûòµ· ºË⁄òËÞ òÓ‚ òÈÚ ò×ȺË⁄. 
  180. <br>
  181. <br>#include 
  182. <br>
  183. <br>int main(void) 
  184. <br>{ 
  185. <br>printf(í Þfrom sea to í Þ); 
  186. <br>printf(í Þshining Cí µ); 
  187. <br>printf(í Þ\ní µ); 
  188. <br>return 0; 
  189. <br>} 
  190. <br>
  191. <br>Although it is different from the first version, it will produce the same output. Each time printf()is called, printing begins at the position where the previous call to printf() left off. If we want to print our phrase on three lines, we can use newline characters. 
  192. <br>
  193. <br>º„ú¡µ ò†«º†Èò§‚ º†Ãò©ÃŒ‡…ºÊÔ ºË⁄º¥·ò§ º§Ì, Œ•‚Œ†Âòµ  Œ®Ûòµ  ò¶Þº©¥(output)òµÃ º§ÌºÓ⁄òÖ· ºÁ… Œ†Âòµ·ºË⁄. printf()óÕ¤òÈÚºÊÔ º§⁄º†È º¶Èº©⁄ò§ Œ‡©, òµ·ò©ÃòÙРòÛ…ò“‰òÙÐòÃÞ ºÀµºÁÞ printf()óÕ¤òÈÚº¥… º¶ º¥‚ Œ•‚ ò×¥òÅÌòÙÐòÃÞº¶ óî óÔúƒ®óÊ‚ºÊÔ òËÞò×ѺÐÞºË⁄. º§ÌòÕ‰ òÜ®ºƒ‹Œ®  òÂŒ®ÞòµÚ ò⁄àòÞÃòÙРòÜ®ºƒ‹òµÚ òµ·òÕ…Œ‚®º¥…(Œ¦‹,phrase) óÔúƒ®óÊ‚óÕÚŒ‡© ò˶ºË⁄º’·, òÜ®ºƒ‹ºÊÔ newline (\n) º‹‚ò×к¥… òÁ‹òÜ’óÕ© òÈÚ ò×ȺË⁄. 
  194. <br>
  195. <br>#include 
  196. <br>
  197. <br>int main(void) 
  198. <br>{ 
  199. <br>printf(í Þfrom sea\ní µ); 
  200. <br>printf(í Þto shining\nC\ní µ); 
  201. <br>return 0; 
  202. <br>} 
  203. <br>
  204. <br>When executed, this program will print 
  205. <br>óÔú¡ÞŒ•‚º×¤òµ· òË⁄óÖɺÐÚòÖ· ò¡ÌòµÃ ºÕÌ, òµ· óÔú¡ÞŒ•‚º×¤òµ  ºË⁄òµÌò†Úº÷… óÔúƒ®óÊ‚ óÕ© Œ†Âòµ·ºË⁄. 
  206. <br>
  207. <br>from sea 
  208. <br>to shining 
  209. <br>C 
  210. <br>
  211. <br>Let us write one additional on this program, one that will box the phrase in a rectangle of asterisks. It will show how each character, including blanks and newline characters, is significant, and when it is executed, it will give some sense of the screen proportions. 
  212. <br>
  213. <br>òµ· óÔú¡ÞŒ•‚º×¤òÞÃòÙРóÕÚºÁÚº¥… ºÍ§º¶ÛòÙ‹ òͤº‡·ò×Ð, Œ•‚ óÕÚºÁںנ òÕÃòÊ⁄óÄ̺ƒ‹òÊ⁄óÀ‹(*)ºÓ⁄òÙРòµÚóÕÞ òÁ‹Œ®ÀóÚÕ òÕÈòµÚ º®ÕòÊ⁄ òµ·òÕ…Œ‚®(Œ¦‹,phrase)Œ®  ºÐ©Œ†Âòµ·ºË⁄. Œ•‚Œ†Âòµ· òË⁄óÖÉ ºÐÚòÙÈòµÃ ºÕÌ º„È ò„‚ºÓ⁄Œ‡… newline(\n)º‹‚ò×к¥… óÏ‹óÕ¤óÕÚºÊÔ Œ®ÀŒ®ÀòµÚ º‹‚ò×кÓ⁄òµÃ º‡·òÙ‹ò⁄àŒ†Âòµ·ºË⁄. Œ•‚Œ†Âòµ  ò⁄ÑòÜÔóÕÞ Œ†Âòµ·Œ‡©, Œ•‚Œ†Âòµ  òÊ⁄óÀ‹ºƒ®òµÚ º„ÃòÞ¤(Œ•©óÚÕ,proportions)òµÚ òÖ·ºÖ⁄ Œ®ÐŒ®ÀòµÃ ò£…Œ†Ì ºÐ© Œ†Âòµ·ºË⁄. 
  214. <br>
  215. <br>In file sea2.c 
  216. <br>
  217. <br>#include 
  218. <br>
  219. <br>int main(void) 
  220. <br>{ 
  221. <br>printf(í Þ\n\n\n\n\n\n\n\n\n\ní µ); 
  222. <br>printf(í Þ              **********************\ní µ); 
  223. <br>printf(í Þ              *   from sea                  *\ní µ); 
  224. <br>printf(í Þ              * to shining C               *\ní µ); 
  225. <br>printf(í Þ              **********************\ní µ); 
  226. <br>printf(í Þ\n\n\n\n\n\n\n\n\n\ní µ); 
  227. <br>
  228. <br>
  229. <br>return 0; 
  230. <br>} 
  231. <br>
  232. <br>1.3 Variables, Expressions, and Assignment 
  233. <br>
  234. <br>We will write a program to convert the distance of a marathon in miles and yards to kilometers. In English units, a marathon is defined to be 26 miles and 385 yards. These numbers are integers. 
  235. <br>
  236. <br>òÜ®ºƒ‹ºÊÔ milesŒ‡… yardsòµÚ º§Èºµ…óÅ⁄òµÚ Œ–®ºƒ‹º¥… kilometersº¡Þ º‡ óÛÚòËÞóÁ‹ Œ†Âòµ·ºË⁄. òÚÀŒ¦›òµÚ ºË¤òÞÃòÙÐòÃÞºÊÔ, º§Èºµ…óÅ⁄òµ  26º§Èòµ… 385òÕ…ºÓÞº¡Þ ò©ÕòµÚºÐÚòÖ· ò×ȺË⁄. òµ·º÷‹óÕÞ òÈÚºÓ⁄òµ  ò©ÕòÈÚºÓ⁄òµ·ºË⁄. 
  237. <br>
  238. <br>To convert miles to kilometers, we multiply by the conversion factor 1.609, a real number. In memory, computers represent integers differently from real. To convert yards to miles, we divide by 1760.0, and, as we shell see, it is essential to represent this number as a real rather as an integer. 
  239. <br>
  240. <br>Milesº¥… kilometersº¡Þ º‡ óÛÔ òËÞóÁ⁄Œ‚® òÞÃóÕ·òÃÞ, òÜ®ºƒ‹ºÊÔ òË⁄òÈÚòµ‚ º‡ óÛÚ òµ‚ò×Р1.609òÙРòµÚóÕÞ Œ‡–òÄÈòµÃ óÕÞºË⁄. º’Ôº“¤ºƒ‹òÙÐòÃÞ, ò»·óÓ¤óîºÓ⁄òµ  òË⁄òÈÚòÛ  ò©ÕòÈÚº¥… ºË⁄º¥‚ Œ†ÂòÞ…º¡Þ óÑÞóÚÃóÕÞºË⁄. yardsº¥… milesº¡Þ º‡ óÛÚòËÞóÁ⁄Œ‚® òÞÃóÕ·òÃÞ, 1760.0òÞ…º¡Þ ºÁÚºÈÃŒ‡©, Œ•‚ºƒ‹Œ‡©, òÜ®ºƒ‹Œ®  º‡·ºÊÔ º®ÔòÛ  Œ®Ûòµ·, òµ· òÈ«ò×к¥… ºÁÚó ºÁ·ºÊÔ ºÍ®òÙкÊÔ ò©ÕòÈÚº‡·ºË⁄ºÊÔ òË⁄òÈÚŒ®  óÕÃòÜÔóÕÚºË⁄.(òË⁄ò§Èò©Àòµ·ºË⁄.) 
  241. <br>
  242. <br>Our conversion program will use variables capable of strong integer values and real values. 
  243. <br>
  244. <br>òÜ®ºƒ‹òµÚ º‡ óÛÚ óÔú¡ÞŒ•‚º×¤òµ  ò©ÕòÈÚóÚÕ Œ®ÒŒ‡… òË⁄òÈÚóÚÕ Œ®ÒòµÚ º‡ òÈÚºÓ⁄òµÃ òÁ‹òÜ’óÕ© Œ†Âòµ·ºË⁄. 
  245. <br>In C, all variables must be declared, or named, at the beginning of the program. A variable name, also called an identifier, consists of a sequence of letters, digits, and underscores, but may not start with a digit. 
  246. <br>
  247. <br>CòÙÐòÃÞºÊÔ, º“¤ºÓ© º‡ òÈÚºÓ⁄òµ· Œ•‚ óÔú¡ÞŒ•‚º×¤òµ· òËÞò×ѺÐÚòÖ· ò§È ºÕÌ òéòÖ‚ºÐÚòÖ·ò§ Œ–®ºÁÚ òµ·ºƒÃ ò§ òÖ·ò§ÃºË⁄. º‡ òÈÚòµÚ òµ·ºƒÃòµ , ºÚÐóÕÞ identifier(óÛÕòµ‚ò×Ð)ºµ…Œ‡© º¶Èºƒ‹º’®, òÈ«ò×к¡Þ òËÞò×ÑóÕÚò§ ºÊÔ òÕʺÊÔ º‹‚ò×кÓ⁄òµÚ òÙ·Œ‡… òÈ«ò×кÓ⁄, Œ•‚ºƒ‹Œ‡© º®Ñò⁄ÃòÙРòµÚóÕ· Œ¦‹òÖºÐÚòÖ·ò§ÃºË⁄. 
  248. <br>
  249. <br>Identifiers should be chosen to reflect their use in the program. In this way, they serve as documentation, making the program more readable. 
  250. <br>
  251. <br>óÛÕòµ‚ò×кÓ⁄(º‡ òÈÚºÓ⁄)òµ  óÔú¡ÞŒ•‚º×¤òÙÐòÃÞ Œ•‚ºÓ⁄òµÚ òÓ®ò×ÃòµÃ º®ÚóÖ¥óÕÚŒ‚® òÞÃóÕ·òÃÞ òéóµºÐÚòÖ· ò©‚òÕ… óÕÞºË⁄. òµ·º÷® º®’º†ÕòÞ…º¡Þ, Œ•‚ºÓ⁄òµ  º§ÌºÓÞºÊÔ óÔú¡ÞŒ•‚º×¤òµÃ º‹‚òÃÞò†Úº÷… ºÍÔ òµ‰òµÃ òÈÚ ò×ÈŒ†Ì óÕ·ò⁄ ºË⁄. 
  252. <br>
  253. <br>In file marathon.c 
  254. <br>
  255. <br>/* The distance of a marathon in kilometers */ 
  256. <br>#include 
  257. <br>
  258. <br>int main(void) 
  259. <br>{ 
  260. <br>int    miles, yards; 
  261. <br>float    kilometers; 
  262. <br>
  263. <br>miles = 26; 
  264. <br>yards = 385; 
  265. <br>kilometers = 1.609 * (miles + yards / 1760.0); 
  266. <br>printf(í Þ\nA marathin is %f kilometers. \n\ní µ, kilometers); 
  267. <br>return 0; 
  268. <br>} 
  269. <br>
  270. <br>The output of the program is 
  271. <br>
  272. <br>A marathon is 42.185970 kilometers. 
  273. <br>
  274. <br>Dissection of the marathon Program 
  275. <br>
  276. <br>/* The distance of a marathon in kilometers. */ 
  277. <br>
  278. <br>Anything written between the characters /* and */ is a comment and is ignored by the compiler. All programs in this book that start with a comment are listed in the index. 
  279. <br>
  280. <br>º‹‚ò×кÓ⁄ /* Œ‡… */ºÓ⁄ òÁ‹òµ·òÙРòÓ®òÙ‹ò§Ã òÖ·ºÖ⁄ Œ†ÂºÓ⁄ºÏàò£…òõ,óÕ·òÃ⁄,òÃ⁄º“Äòµ·º’® ò»·óÌÌòµ…º÷‹òÙÐòµÚóÕ· º‹·òË޺˄óÕÞºË⁄. òµ· ò–Ä òÕÈòÙÐòÃÞòµÚ º“¤ºÓ© óÔú¡ÞŒ•‚º×¤ºÓ⁄òµ  indexòÕÈòÙÐòÃÞ list ºÐÚòÖ·ò§Ã ò£…òõº‹‚Œ‡… óÕ¤Œ»Ú òËÞò×ÑóÕÞºË⁄. 
  281. <br>
  282. <br>int    miles, yards; 
  283. <br>
  284. <br>This is a declaration. Declarations and statements end with a semicolon. int is a keyword and is one of the fundamental types of the language. It informs the compiler that the variables flowing it are type int and are to take on integer values. Thus, the variables miles and yards in this program are of type int. 
  285. <br>
  286. <br>òµ·Œ†Âòµ  òéòÖ‚òµ·ºË⁄. òéòÖ‚ºÓ⁄Œ‡… º‹‚ò×¥ºÓ⁄òµ  òºfl‚ò‰Þº¡©Œ‡… óÕ¤Œ»Ú ºÀµºÁÞºË⁄. int ºÊÔ óÁ⁄òÝ̺ÓÞ(keyword)òµ·º’® òÖ‚òÖ·òµÚ Œ‚®º‡‚ò©Àòµ‚ óÚÕ(types)ºÓ⁄ ò⁄ÑòµÚ óÕÚºÁÚòµ·ºË⁄. Œ•‚Œ†Âòµ  ò»·óÌÌòµ…º÷‹òÙÐŒ†Ì º‡ òÈÚºÓ⁄òµ· int óÚÕòµÃ ºÔ®º¥‚ºË⁄ºÊÔ Œ†ÂŒ‡… ò©ÕòÈÚóÚÕòµÚ Œ®ÒºÓ⁄òµÃ ò•¤óÕÚŒ‚® òÞÃóÕÞ Œ†Âò×ÃòµÃ òÕ̺©⁄ò⁄ ºË⁄. Œ•‚º÷‹ºfl º¡Þ, óÔú¡ÞŒ•‚º×¤ òÕÈòÙÐòÃÞ milesòÛ  yardsºµ…ºÊÔ º‡ òÈÚºÓ⁄òµ  int óÚÕòµ·ºË⁄. 
  287. <br>
  288. <br>float    kilometers; 
  289. <br>
  290. <br>This is a declaration. float is a keyword and is one of the fundamental types of the language. It informs the compiler that the variables following it are of type float and are to take on real values. Thus, the variable kilometers in this program is of type float. 
  291. <br>
  292. <br>òµ·Œ†Âòµ  òéòÖ‚òµ·ºË⁄. float ºÊÔ óÁ⁄òÝ̺ÓÞ(keyword)òµ·Œ‡© òÖ‚òÖ·òµÚ Œ‚®º‡‚ò©Àòµ‚ óÚÕ(types)ºÓ⁄ò⁄ÑòµÚ óÕÚºÁÚòµ·ºË⁄. Œ•‚Œ†Âòµ  ò»·óÌÌòµ…º÷‹òÙÐŒ†Ì òÕ̺©⁄ò⁄ ºË⁄. º‡ òÈÚºÓ⁄òµ· floatóÚÕòµÃ ºÔ®º¥·Œ‡© òË⁄òÈÚòµÚ Œ®ÒºÓ⁄òµÃ ò•¤óÕÞºË⁄ºÊÔ Œ†ÂòµÃ. Œ•‚º÷‹ºfl º¡Þ, óÔú¡ÞŒ•‚º×¤òÙÐòÃÞ º‡ òÈÚ kilometers ºÊÔ floatóÚÕòµ·ºË⁄. 
  293. <br>
  294. <br>miles = 26; 
  295. <br>yards = 385; 
  296. <br>
  297. <br>These are assignment statements. The equal sign is an assignment operator. The two numbers 26 and 385 are integer constants. The value 26 is assigned to the variable miles. The value 385 is assigned to the variable yards. 
  298. <br>
  299. <br>òµ·Œ†ÂºÓ⁄òµ  óÕ©ºË„ º‹‚ºÓ⁄òµ·ºË⁄. òµ·ó Ã Œ‚®óÚ‚ºÊÔ óÕ©ºË„ òÙ®òÁ®ò×Ðòµ·ºË⁄. ºÑÐŒ®ÞòµÚ òÈ«ò×кÓ⁄ 26Œ‡… 385ºÊÔ ò©ÕòÈÚ òÂÀòÈÚºÓ⁄òµ·ºË⁄. Œ®Ò 26òµ  º‡ òÈÚ milesòÙРóÕ©ºË„ºÐÚòÖ· ò§ÃºË⁄. Œ®Ò 385ºÊÔ º‡ òÈÚ yardsòÙРóÕ©ºË„ºÐÚòÖ· ò§ÃºË⁄. 
  300. <br>
  301. <br>Kilometers = 1.609 * (miles + yards / 1760.0); 
  302. <br>
  303. <br>This is assignment statement. The value of the expression on the right side of the equal sign is assigned to the variable kilometers. The operator *, +, and / stand for multiplication, addition, and division, respectively. Operations inside parentheses are performed first. Because division has higher precedence than addition, the value of the sub expression 
  304. <br>
  305. <br>òµ·Œ†Âòµ  óÕ©ºË„º‹‚òµ·ºË⁄. òµ·ó Ã Œ‚®óÚ‚òµÚ òÚ⁄º¥‚ò“‰ó΂òÙРò×ȺÊÔ óÑÞóÚàŒ®Òòµ  º‡ òÈÚ kilometersòÙРóÕ©ºË„ºÐÚòÖ· ò§ÃºË⁄. òÙ®òÁ®ò×Р *, +, Œ•‚ºƒ‹Œ‡© / òµ  ò©ÞŒ®ÀŒ®À Œ‡–òÄÈ, ºÍ§òÄÈ, ºÁÚºÈÙòÄÈòµÚ òÕ‰ò„›,òÕ‰ò×Ð,ºÌ òË©óÕ·òÃÞ òÓ®òµ·ºÊÔ Œ†Â(stand for)òµ·ºË⁄. ()Œ·ÃóÚ‚ òÕÈòÙРò×ȺÊÔ òÙ®òÁ®ò×кÓ⁄òµ  ò†«º†Èò§‚º¡Þ òÈÚóÖɺÐÚòÖ· ò§ÃºË⁄. ºÁÚºÈÙòÄÈòµ  ºÍ§òÄȺ‡·ºË⁄ ºÅÒòµ  òÜ®òéòÈÞòÞú¥… Œ®ÖŒ‚® ºÕ̺‹‚òÙÐ, óÕÚòÞàóÑÞóÚÃ(subexpression)Œ®Ò yards / 1760.0 
  306. <br>
  307. <br>yards / 1760.0 
  308. <br>
  309. <br>is calculated first. (See Appendix E, í ÞOperator precedence and Associativity.í µ) That value is added to the value of the variable miles to produce a value that is then multiplied by 1.609. This final value is then assigned to the variable kilometers. 
  310. <br>
  311. <br>òµ  º¤…ò©  Œ‡ÃòÁ®ºÐÚòÖ· ò§ÃºË⁄. Œ•‚ Œ®Òòµ  Œ•‚ºƒ‹Œ‡©ºÁÚòÃÞ 1.609òÙРòµÚóÕ· Œ‡–óÕÚòÙ‹ò§Ã Œ®ÒòµÃ òÁ®ò¶ÞóÕÚŒ‚® òÞÃóÕ· º‡ òÈÚ milesòµÚ Œ®ÒòÙРºÍÔóÕÚòÙ‹ ò§ÃºË⁄. º§Èò§ º§É Œ®Òòµ  Œ•‚ºƒ‹Œ‡© ºÁÚòÃÞ º‡ òÈÚ kilometersòÙРóÕ©ºË„ºÐÚòÖ· ò§ÃºË⁄. 
  312. <br>
  313. <br>printf(í Þ\nA marathon is %f kilometers.\n\ní µ, kilometers); 
  314. <br>
  315. <br>This is a statement that invokes, or calls, the printf() function. The function printf() can have a variable number of arguments. The first argument is always a string, called the control string. The control string in this example is 
  316. <br>
  317. <br>òµ· º‹‚ò×¥òµ  printf()óÕ¤òÈÚº¥… Œ® ò©‚òÚ⁄Œ–®ºÁÚ º¶Èº÷‹ºÁ‚ºË⁄. óÕ¤òÈÚ printf()ºÊÔ ºÏĺƒ‰º‡ òÈÚºÓ⁄òµÚ º‡ òÈÚ òÈ«ò×к¥…(Œ•‚ºÂ¥ º‡ òÈÚº¥…òµ·ºµ…Œ‡© óÕ·òõóÕÚºÊÔ Œ†Âòµ· ºÍÔ ò¢ËòµÃ ºÓfl,a variable number) Œ® ò§È òÈÚ ò×ȺË⁄. ò†«º†Èò§‚ Œ‡©ò©Õº‡ òÈÚºÊÔ control stringòµ·ºµ… º¶Èºƒ‹ºÊÔ óÕÚºÁÚòµÚ º‹‚ò×ÐòÙ·òµ·ºË⁄. òµ· òÚÈòÙÐòÃÞ control stringòµ  òÕú×ÚòÛ  Œ®ÛºË⁄. 
  318. <br>
  319. <br>
  320. <br>í Þ\nA marathon is %f kilometers. \n\ní µ 
  321. <br>
  322. <br>It is the first argument to the function printf(). Inside this string is the conversion specification, or format, %f. The formats in a control string, if any, are matched with the remaining arguments in the printf() function. 
  323. <br>
  324. <br>òµ·Œ†Âòµ  printf()óÕ¤òÈÚº¥… óÖ¥óÕÚºÊÔ ò†«º†Èò§‚ Œ‡©ò©Õº‡ òÈÚòµ·ºË⁄. òµ· º‹‚ò×ÐòÙ· òÕÈòÙкÊÔ ò©ÃóÛÚ,º‡ óÛÚòÁ‹óÕ›(conversion specification), óÚ„òµ  óÚÕò˵òµ· ºÐÚºÊÔ %f Œ®  ò×ȺË⁄. control string òÕÈòÙÐòÃÞòµÚ óÚÕò˵òµ (conversion specification, format, òÚȺ¥…ºÓ⁄º’· òµ· º‹‚ò×¥òÙÐòÃÞ %fºÊÔ), º§ÌòÕ‰ ò×ȺË⁄º’·, printf()óÕ¤òÈÚ òÕÈòÙÐòÃÞòµÚ ºÁ¤òÕÃò×ȺÊÔ Œ‡©ò©Õº‡ òÈÚºÓ⁄Œ‡… óÕ¤Œ»Ú òÖ·òÜ‚ºƒ®ºË⁄. 
  325. <br>
  326. <br>In this case, %f is matched with the argument kilometers. Its effect is to print the value of the variable kilometers as a floating-point number and insert it into the print stream where the format %f occurs. 
  327. <br>
  328. <br>òµ· Œ†‰òÜ®òÙÐòÃÞºÊÔ, %fºÊÔ Œ‡©ò©Õº‡ òÈÚ kilometersòÛ  óÕ¤Œ»Ú ò§µòµ· ºÐÞºË⁄.(òÖ·òÜ‚ºƒ®ºË⁄). Œ•‚Œ†ÂòµÚ Œ†®Œ‡…ºÊÔ, floating-point number òÛ  format %fŒ®  º®ÞòµóÕÚòÙ‹ print stream òÕÈòÞ…º¡Þ Œ•‚Œ†ÂòµÃ(floating-point numberº¥…) ò§ÑòÖ·ºÃ£ºÊÔ, º‡ òÈÚ kilometersòµÚ Œ®ÒòµÃ óÔúƒ®óÊ‚óÕÞºË⁄.
  329. <br><span id="'1'"></span></td></tr></table><table bgcolor=#ffffff width=100% border=0 cellpadding=4 cellspacing=0 align=center><tr bgcolor=#eeeeee><td width=100% align=left nowrap>ºÓ–º¡µóÌÌòµ… òÙÅòµÌ</td></tr></table><br>
  330.  
  331. <form method=post enctype='multipart/form-data' action='/board/bbs.php3?board=board&line=thred&fld=&nws=&page=49&id=164&keyword=&flag=&a_o=&nospam_str=194' onsubmit='return check_submit();'><input type=hidden name=mode value=insert><input type=hidden id='subjectchk' name='fields[subject]' value='Re: ABookOnC Chapter 1 - 1.3'><table bgcolor=#ffffff width=100% border=0 cellpadding=0 cellspacing=0 align=center><tr><td bgcolor=#ffffff align=right><textarea id='contentschk' name='fields[contents]' rows=5 cols=80></textarea></td></tr><tr><td align=right><table width=460 border=0 cellpadding=0 cellspacing=0><tr align=right><td nowrap>  òµ· ºƒÃ</td><td><input type=text id='namechk' name='fields[name]' size=10 maxlength=12 value=''></td><td nowrap>  òÕÔ óÚ‚</td><td><input type='password' id='passwdchk' name='fields[passwd]' size=10 maxlength=8></td><td nowrap>  º‡·òÕÈò‰ÔºÓÞ </td><td><input type=text id='nospamchk' name='fields[nospamchk]' size=5 maxlength=2></td><td><img src='/counter/digit/brush/9.gif' valign=middle><img src='/counter/digit/brush/5.gif' valign=middle></td><td> <input type='Submit' name='Submit' value=' Post '></td></tr></table></td></tr></table></form>
  332.  
  333. <table bgcolor=#ffffff width=100% border=0 cellpadding=1 cellspacing=1 align=center><tr height=24 bgcolor=#666666><td width=50 align=center nowrap><font color=#ffffff><b>º†ÈóÚ‚</b></font></td><td width=90 align=center nowrap><font color=#ffffff><b>ò×ÑòÖò×Ð</b></font></td><td width=90 align=center nowrap><font color=#ffffff><b>ºÁ©ò§Þ</b></font></td><td width=50 align=center nowrap><font color=#ffffff><b>ò¡®óÜÌ</b></font></td><td width=100% align=center nowrap><font color=#ffffff><b>ò©Þ    º“’</b></font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 169, Virtual number 75, Included 19 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>75</td><td width=80 align=center nowrap><a href="mailto:goodwolf@white.chungbuk.ac.kr">GoodWolf</a></td><td width=90 align=center nowrap>2001-01-29</td><td width=50 align=center nowrap>647</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=169&fld=&nws=&page=49&keyword=&flag=&a_o='>NeXTòÙÐòÃÞ òÕÃóÌÌò„Úº×Ñ phpº×Ñ MysQL..òÖ·ºÖ»Œ†Ì óÕÚºÁÚòÙ‹??</a> <font color=orange>(1)</font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 168, Virtual number 74, Included 2 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>74</td><td width=80 align=center nowrap><a href="mailto:kotani@chollian.net">ò¦ÞòÊ„óµ‹</a></td><td width=90 align=center nowrap>2001-01-29</td><td width=50 align=center nowrap>647</td><td width=100% nowrap>  <img src='./image/bwun.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=168&fld=&nws=&page=49&keyword=&flag=&a_o='>òÕ…ºÏÛ Œ® ºÊÔŒ‚‚.... Œ•‚Œ†Âòµ· 200mºÁÚ ??</a> <font color=orange></font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 167, Virtual number 73, Included 11 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>73</td><td width=80 align=center nowrap><a href="mailto:Narzisse@borahome.net">ºÁÚòÚÀò†©</a></td><td width=90 align=center nowrap>2001-01-21</td><td width=50 align=center nowrap>633</td><td width=100% nowrap>  <img src='./image/bwun.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=167&fld=&nws=&page=49&keyword=&flag=&a_o='>ABookOnC º¥… òÚ‹ºƒ® òµ·òÞ©</a> <font color=orange></font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 166, Virtual number 72, Included 94 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>72</td><td width=80 align=center nowrap><a href="mailto:Narzisse@borahome.net">ºÁÚòÚÀò†©</a></td><td width=90 align=center nowrap>2001-01-21</td><td width=50 align=center nowrap>612</td><td width=100% nowrap>  <img src='./image/bwun.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=166&fld=&nws=&page=49&keyword=&flag=&a_o='>ABookOnC Chapter 6 - 6.2 Source code Œ„Ìò§ </a> <font color=orange></font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 165, Virtual number 71, Included 300 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>71</td><td width=80 align=center nowrap><a href="mailto:Narzisse@borahome.net">ºÁÚòÚÀò†©</a></td><td width=90 align=center nowrap>2001-01-21</td><td width=50 align=center nowrap>495</td><td width=100% nowrap>  <img src='./image/bwun.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=165&fld=&nws=&page=49&keyword=&flag=&a_o='>ABookOnC Chapter 5 - 5.4</a> <font color=orange></font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 164, Virtual number 70, Included 321 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>70</td><td width=80 align=center nowrap><a href="mailto:Narzisse@borahome.net">ºÁÚòÚÀò†©</a></td><td width=90 align=center nowrap>2001-01-21</td><td width=50 align=center nowrap>903</td><td width=100% nowrap>  <img src='./image/bwre.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=164&fld=&nws=&page=49&keyword=&flag=&a_o='>ABookOnC Chapter 1 - 1.3</a> <font color=orange></font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 163, Virtual number 69, Included 6 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>69</td><td width=80 align=center nowrap><a href="mailto:onion@onion.sarang.net">onion</a></td><td width=90 align=center nowrap>2001-01-16</td><td width=50 align=center nowrap>655</td><td width=100% nowrap>  <img src='./image/bwun.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=163&fld=&nws=&page=49&keyword=&flag=&a_o='>[òסºË·] òÕÃòµ· XXóÌÔº©⁄ºµ…....ò”‹ò”‹ò”‹...</a> <font color=orange></font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 159, Virtual number 68, Included 36 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>68</td><td width=80 align=center nowrap><a href="mailto:kotani@chollian.net">ò¦ÞòÊ„óµ‹</a></td><td width=90 align=center nowrap>2001-01-16</td><td width=50 align=center nowrap>728</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=159&fld=&nws=&page=49&keyword=&flag=&a_o='>òË‹Œ®ÀóÕÞ Œ‡©ºfl…..òµ·Œ–‚ òÖ·ºÖ»Œ†Ì óÒ òÖ·òÕ… óÕÚò§ ?</a> <font color=orange>(1)</font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 158, Virtual number 67, Included 17 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>67</td><td width=80 align=center nowrap>ºÁÚòÚÀò†©</td><td width=90 align=center nowrap>2001-01-16</td><td width=50 align=center nowrap>661</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=158&fld=&nws=&page=49&keyword=&flag=&a_o='>òÛÞ ò©Þ Œ‚ òÙРºÌ óÕÞ ºË¦òµ  òÕÈóÕ·ò£…òËÞºÁÚòÜÔ??</a> <font color=orange>(1)</font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 157, Virtual number 66, Included 8 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>66</td><td width=80 align=center nowrap><a href="mailto:onion@onion.sarang.net">onion</a></td><td width=90 align=center nowrap>2001-01-15</td><td width=50 align=center nowrap>770</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=157&fld=&nws=&page=49&keyword=&flag=&a_o='>[òסºË·] Œ®ÃºË¤óÕÚŒ†Ì óÕÞŒ‚  òÁ‹òÜ’º†ÕòµÃ ò©Þ óÛÈòÙРòÚ‹º©‚òʦºËȺË⁄..</a> <font color=orange>(1)</font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 145, Virtual number 65, Included 6 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>65</td><td width=80 align=center nowrap><a href="mailto:onion@onion.sarang.net">onion</a></td><td width=90 align=center nowrap>2001-01-14</td><td width=50 align=center nowrap>740</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=145&fld=&nws=&page=49&keyword=&flag=&a_o='>[ò§Èº‹‚] openstep òÙÐòÃÞ óÕÞŒ‚ òµ·òÜÔ...</a> <font color=orange>(11)</font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 141, Virtual number 64, Included 14 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>64</td><td width=80 align=center nowrap>ºÁÚòÚÀò†©</td><td width=90 align=center nowrap>2001-01-13</td><td width=50 align=center nowrap>760</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=141&fld=&nws=&page=49&keyword=&flag=&a_o='>ºÃ¥òÊ⁄óÊ‚òÙÐòÃÞ óÕÞŒ‚  óÏ®óÊ‚....</a> <font color=orange>(2)</font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 140, Virtual number 63, Included 11 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>63</td><td width=80 align=center nowrap><a href="mailto:kotani@chollian.net">ò¦ÞòÊ„óµ‹</a></td><td width=90 align=center nowrap>2001-01-12</td><td width=50 align=center nowrap>687</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=140&fld=&nws=&page=49&keyword=&flag=&a_o='>ºÁÚò×ÚºÁÞ º§Îòµ· òµÑòÝÐóÕ· ò£…òÂòÜÔ</a> <font color=orange>(2)</font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 135, Virtual number 62, Included 11 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>62</td><td width=80 align=center nowrap><a href="mailto:cube@cubem.com">Œ„ ò§ÃòÈÚ</a></td><td width=90 align=center nowrap>2001-01-12</td><td width=50 align=center nowrap>610</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=135&fld=&nws=&page=49&keyword=&flag=&a_o='>òʄ󵋺ÏàóÛÈóÎÚòµ·ò¥Ðº¥… º§ÌºÓÞºÊÔŒ¦‹ºÁÚ...</a> <font color=orange>(3)</font></td></tr><tr height=24 bgcolor=#ffffff onMouseOver="this.style.backgroundColor='#ffffff';window.status=('Physical number 125, Virtual number 61, Included 9 lines');return true;" onMouseOut="this.style.backgroundColor='#ffffff'; window.status=('');return true;"><td height=24 width=50 align=center nowrap>61</td><td width=80 align=center nowrap><a href="mailto:ºÁÚ@òÜ®ºƒ‹ò§Ñ">NONUKE</a></td><td width=90 align=center nowrap>2001-01-10</td><td width=50 align=center nowrap>722</td><td width=100% nowrap>  <img src='./image/bwtx.gif' border=0 align=absmiddle> <a href='/board/bbs.php3?board=board&line=thred&mode=view&id=125&fld=&nws=&page=49&keyword=&flag=&a_o='>º®ÔòÜÔº¥… óÌÔŒ‡© òµ·Œ–‚ òÁ‹º†Ãº©⁄?</a> <font color=orange>(4)</font></td></tr></table><table bgcolor=#ffffff width=100% border=0 cellpadding=4 cellspacing=1 align=center><tr bgcolor=#eeeeee><td align=center><a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=40&keyword=&flag=&a_o='>íÙ </a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=41&keyword=&flag=&a_o='>[41]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=42&keyword=&flag=&a_o='>[42]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=43&keyword=&flag=&a_o='>[43]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=44&keyword=&flag=&a_o='>[44]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=45&keyword=&flag=&a_o='>[45]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=46&keyword=&flag=&a_o='>[46]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=47&keyword=&flag=&a_o='>[47]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=48&keyword=&flag=&a_o='>[48]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=49&keyword=&flag=&a_o='><font color='red'>[49]</font></a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=50&keyword=&flag=&a_o='>[50]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=51&keyword=&flag=&a_o='>íÖ¶</a></td></tr></table>
  334.  
  335. <a name="page_bottom"></a><form method=post action='/board/bbs.php3?board=board&line=thred&fld=&nws=&page=&keyword=&flag=&a_o='><table width=100% border=0 cellpadding=0 cellspacing=1 align=center><tr><td align=left><a href='/board/bbs.php3?board=board&line=thred&mode=list&fld=&nws=&page=49&keyword=&flag=&a_o='>[º“’º¡µº‡·Œ‚®]</a> <a href='/board/bbs.php3?board=board&line=thred&mode=new&fld=&nws=&page=49&keyword=&flag=&a_o='>[Œ‚ òÓ®Œ‚®]</a> <br><br></td><td align=right><select name=flag><option value='subject' selected>ò©Þº“’ <option value='contents'>ºÁ·òÜ’ <option value='name'>òµ·ºƒÃ <option value='all'>ò©Ãò†· </select> <input type=search results name=keyword size=20 maxlength=50 value=''> <select name=a_o><option value='AND' selected>AND <option value='OR'>OR </select> <input type=submit value='Search'><br><br></td></tr></table>
  336.  
  337. </td></tr><tr><td align=center valign=bottom><br><a href='/board/rss2.php?items=active'><img src='/images/rssicon.gif' width=15 height=15></a> <img src='/images/copyright.gif' border=0></td></tr><tr><td height=40></td></tr></table></form></div></body></html>
  338.  
  339.