c语言的艺术.docx
- 文档编号:24511712
- 上传时间:2023-05-28
- 格式:DOCX
- 页数:6
- 大小:18.96KB
c语言的艺术.docx
《c语言的艺术.docx》由会员分享,可在线阅读,更多相关《c语言的艺术.docx(6页珍藏版)》请在冰豆网上搜索。
c语言的艺术
C语言的科学与艺术
Welcome!
Bypickingupthisbook,youhavetakenastepintotheworldofcomputerscience--afieldofstudythathasgrownfromalmostnothinghalfacenturyagotobecomeoneofthemostvibrantandactivedisciplinesofourtime.
Overthattime,thecomputerhasopenedupextraordinarypossibilitiesinalmosteveryareaofhumanendeavor.Businessleaderstodayareabletomanageglobalenterprisesonanunprecedentedscalebecausecomputersenablethemtotransferinformationanywhereinafractionofasecond.Scientistscannowsolveproblemsthatwerebeyondtheirreachuntilthecomputermadethenecessarycal-culationspossible.Filmmakersusecomputerstogeneratedramaticvisualeffectsthatareimpossibletoachievewithoutthem.Doctorscandeterminemuchmoreaccuratelywhatisgoingoninsideapatientbecausecomputershaveenabledamassivetransformationinthepracticeofmedicine.
Computersareaprofoundlyempoweringtechnology.Theadvanceswehaveseenuptonowaresmallcomparedtowhatwewillseeinthenextcentury.Computerswillplayamajorroleinshapingthatcentury,justastheyhavethelast50years.
Thoseofyouwhoarestudentstodaywillsooninherittheresponsibilityofguidingthatprogress.Asyoudoso,knowinghowtousecomputerscanonlyhelp.
Likemostskillsthatareworthknowing,learninghowcomputersworkandhowtocontroltheirenormouspowertakestime.Youwillnotunderstanditallatonce.Butyoumuststartsomewhere.Twenty-fivecenturiesago,theChinesephilosopherLao-tzuobservedthatthelongestjourneybeginswithasinglestep.Thisbookcanbeyourbeginning.
Formanyofyou,however,thefirststepcanbethehardesttotake.Manystudentsfindcomputersoverwhelmingandimaginethatcomputerscienceisbeyondtheirreach.Learningthebasicsofprogramming,however,doesnotrequireadvancedmathematicsoradetailedunderstandingofelectronics.Whatmattersinprogrammingiswhetheryoucanprogressfromthestatementofaproblemtoitssolution.Todoso,youmustbeabletothinklogically.Youmusthavetheneces-
sarydisciplinetoexpressyourlogicinaformthatthecomputercanunderstand.Perhapsmostimportantly,youmustbeabletoseethetaskthroughtoitscompletionwithoutgettingdiscouragedbydifficultiesandsetbacks.Ifyoustickwiththeprocess,youwilldiscoverthatreachingthesolutionissoexhilaratingthatitmorethanmakesupforanyfrustrationsyouencounteralongtheway.
ThisbookisdesignedtoteachyouthefundamentalsofprogrammingandthebasicsofC,whichisthedominantprogramminglanguageinthecomputingindustrytoday.Ittreatsthewhysofprogrammingaswellasthehows,togiveyouafeelfortheprogrammingprocessasawhole.Italsoincludesseveralfeaturesthatwillhelpyoufocusontheessentialpointsandavoiderrorsthatslowyoudown.Thenextfewpagessummarizethesefeaturesandexplainhowtousethisbookeffectivelyasyoubeginyourjourneyintotheexcitingworldofcomputerscience.
C语言教程前言
ABookonCconveysanappreciationforboththeelegantsimplicityandthepowerofthisgeneral-purposeprogramminglanguage.Bypresentinginteractiverunningprogramsfrommanyapplicationareas,thisbookdescribestheANSIversionoftheClanguage.Thecompletelanguageispresentedinastep-by-stepmanner,alongwithmanycompleteworkingprograms.
Whereappropriate,wediscussthedifferencesbetweentraditionalCandANSIC.(TraditionalCstillremainsinwideuse.)Dozensofexampleprogramsareavailabletoillustrateeachimportantlanguagefeature,andmanytablessummarizekeyinformationandprovideeasyaccessforlaterreference.Eachchapterendswithasummaryandexercises.Thesummaryreviewskeyelementspresentedinthechapter,andtheexercisesaugmentandextendthetext.
Thisbookassumesageneral-purposeknowledgeoftheClanguage.Itisintendedforuseineitherafirstorsecondprogrammingcourse.However,itcanbereadilyusedinconjunctionwithcoursesontopicssuchascomparativeprogramminglanguages,computationallinguistics,datastructures,databasesystems,fractalgeometry,graphics,numericalanalysis,operatingsystems,programmingmethodology,andscientificapplications.Cissuitableforapplicationsfromeachofthesedomains,andallfeaturesofCneededtocodesuchapplicationsareexplained.Thisbookisappropriateforadatastructurescoursebecauseadvanceddatastructuringfeaturessuchasenumerationtypes,unions,self-referentialstructures,andraggedarraysarediscussed.ForoperatlngsystemscoursesconcernedwithUNIXorWindows95/NT,thebookexploresthefile
structureandsystemsroutinesthatenabletheCprogrammertoaddtoexistingsysternslibrariesandunderstandtheCcodeunderlyingtheoperatingsystem.Forapplicationsprogrammingandsoentificprogramming,thereisdiscussionofhowtowritesamplefunctionlibraries.Statistics,rootfinding,sorting,textmanipulation,filehandling,andgameplayingareallrepresentedwithworkingcode.
NewJavaSection.InChapter14,"MovingfromCtoJava,"wediscusshowtheCprogrammercanverynaturallyandeasilybeginprogramminginJava,alanguageofinterestforworkontheInternet.TheJavaprogramminglanguageborrowsideasfrombothCandC++andisdesignedtoruninamachine-andsystem-independentmanner.ThismakesitsuitableforInternetwork,suchaswritingappletsforWebpagesthatgetusedbybrowsers.BecauseJavaisanextensionofCandC++,itisreadilylearnedbytheCprogrammer.
CompleteANSICLanguage.Computerprofessionalswillhaveaccesstoacompletetreatmentofthelanguage,includingenumerationtypes,listprocessing,andtheoperatingsysteminterface.Chapter1,"AnOverviewofC,"presentsanoverviewofthelanguage.Afterreadingthischapter,theprofessionalwillalreadybeabletowriteCcode.
Sincethechaptersareself-contained,theknowledgeablereadercanskiptoparticularsectionsasneeded.Chapter11,"Input/OutputandtheOperatingSystem,"givesathoroughintroductiontotheconnectionstotheoperatingsystem.ThisinformationwillbenefittheprofessionalsystemsprogrammerneedingtouseCtoworkwithinanMSDOSorUNIXenvironment.
InteractiveEnvironment.Thisbookiswrittenentirelywiththemoderninteractiveenvironmentinmind.Experimentationisencouragedthroughout.Keyboardandscreeninput/outputistakenasthenorm,anditsattendantconcernsareexplained.Thus,thebookisappropriateforusersofsmallhomeandbusinesscomputersaswellastousersoflargeinteractivesystems.WeassumethatthereaderwillhaveaccesstoaninteractiveANSICsystem.Duringthewritingofthisbook,weusedanumberofdifferentCsystems:
variousBorlandandMicrosoftcompilersrunningonIBM-compatiblePentiummachines,theGNUgcccompilerandnativecompilersrunningonvariousworkstationsfromDEC,SGI,andSun,andtheCcompilerthatrunsontheCraysupercomputerinSanDiego.
WorkingCode.Ourapproachtodescribingthelanguage'istouseexamples,explanation,andsyntax.Workingcodeisemployedthroughout.Smallbutusefulexamplesareprovidedtodescribeimportanttechnicalpoints.Smallbecausesmalliscomprehensible.Usefulbecauseprogrammingisbasedonahierarchyofbuildingblocksandultimatelyispragmatic.Theprogramsandfunctionsdescribedinthebookcanbeusedinactualsystems.Theauthors'philosophyisthatoneshouldexperimentandenjoy.
Dissections.Weusehighlighted"dissections"onmanyprogramsandfunctionsthroughoutthebook.Dissectionisauniquepedagogicaltoolfirstdevelopedbytheauthorsin1984toilluminatekeyfeaturesofworkingcode.Adissectionissimilartoastructuredwalk-throughofthecode.Itsintentionistoexplaintothereadernewlyencounteredprogrammingelementsandidiomsfoundinworkingcode.
FlexibleOrganization.Thisbookisconstructedtobeveryflexibleinitsuse.Chapter1,
"AnOverviewofC,"isintwoparts.Thefirstpartexplainsthecrucialprogrammingtechniquesneededforinteractiveinput/output,materialthatmustbeunderstoodbyall.ThesecondpartofChapter1goesontosurveytheentirelanguageandwillbecomprehensibletoexperiencedprogrammersfamiliarwithcomparablefeaturesfromotherlanguages.Thissecondpartcanbepostponedinafirstprogrammingcourse.Caution:
BeginningprogrammersshouldpostponethesecondpartofChapter1.
Chapter2,"LexicalElements,Operators,andtheCSystem,"describesthelexicallevel
ofthelanguageandsyntacticrules,whichareselectivelyemployedtoillustrateClanguageconstructs.TheinstructormaydecidetoteachBackus-Naur-Form(BNF)notationasdescribedinChapter2ormayomititwithoutanylossofcontinuity.ThebookusesBNF-stylesyntacticdescriptionssothatthestudentcanlearnthisstandardformofprogramminglanguagedescription.Inaddition,languagecomponentsarethoroughlydescribedbyexampleandordinaryexplanation.
ReferenceWork.ThisbookisdesignedtobeavaluablereferencetotheClanguage.Throughoutthebook,manytablesconciselyillustratekeyareasofthelanguage.ThecompleteANSICstandardlibrary,alongwithitsassociatedheaderfiles,isdescribedintheAppendixA,"TheStandardLibrary."Sectionsintheappendixaredevotedtoexplainingeachofthestandardheaderfilessuchasctype,h,stdio,h,andstring,h.Whereappropriate,examplecodeisgiventoillustratetheuseofaparticularconstructorfunction.
InAppendixB,"LanguageSyntax,"weprovidethecompletesyntaxoftheClanguage.InAppendixC,"ANSICComparedtoTraditionalC,"welistthemajordiffere
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 艺术
![提示](https://static.bdocx.com/images/bang_tan.gif)