資源描述:
《Expert C Programming.pdf》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在學(xué)術(shù)論文-天天文庫。
1、ExpertCProgramming:DeepCSecretsByPetervanderLindenIntroductionCcode.Ccoderun.Runcoderun…please!—BarbaraLingAllCprogramsdothesamething:lookatacharacteranddonothingwithit.—PeterWeinbergerHaveyouevernoticedthatthereareplentyofCbookswithsuggestivenameslikeCTrapsa
2、ndPitfalls,orTheCPuzzleBook,orObfuscatedCandOtherMysteries,butotherprogramminglanguagesdon'thavebookslikethat?There'saverygoodreasonforthis!Cprogrammingisacraftthattakesyearstoperfect.AreasonablysharppersoncanlearnthebasicsofCquitequickly.Butittakesmuchlonger
3、tomasterthenuancesofthelanguageandtowriteenoughprograms,andenoughdifferentprograms,tobecomeanexpert.Innaturallanguageterms,thisisthedifferencebetweenbeingabletoorderacupofcoffeeinParis,and(ontheMetro)beingabletotellanativeParisiennewheretogetoff.Thisbookisana
4、dvancedtextontheANSICprogramminglanguage.ItisintendedforpeoplewhoarealreadywritingCprograms,andwhowanttoquicklypickupsomeoftheinsightsandtechniquesofexperts.Expertprogrammersbuildupatoolkitoftechniquesovertheyears;agrab-bagofidioms,codefragments,anddeftskills
5、.Theseareacquiredslowlyovertime,learnedfromlookingovertheshouldersofmoreexperiencedcolleagues,eitherdirectlyorwhilemaintainingcodewrittenbyothers.OtherlessonsinCareself-taught.AlmosteverybeginningCprogrammerindependentlyrediscoversthemistakeofwriting:if(i=3)i
6、nsteadof:if(i==3)Onceexperienced,thispainfulerror(doinganassignmentwherecomparisonwasintended)israrelyrepeated.Someprogrammershavedevelopedthehabitofwritingtheliteralfirst,likethis:if(3==i).Then,ifanequalsignisaccidentallyleftout,thecompilerwillcomplainabouta
7、n"attemptedassignmenttoliteral."Thiswon'tprotectyouwhencomparingtwovariables,buteverylittlebithelps.The$20MillionBugInSpring1993,intheOperatingSystemdevelopmentgroupatSunSoft,wehada"priorityone"bugreportcomeindescribingaproblemintheasynchronousI/Olibrary.Theb
8、ugwasholdingupthesaleof$20millionworthofhardwaretoacustomerwhospecificallyneededthelibraryfunctionality,sowewereextremelymotivatedtofindit.Aftersomeintensivedebuggingsessions,theproblemwa