圖書簡介
本書是印度各大學使用最廣的C語言程式設計教材之一。
本書旨在教授讀者如何使用C語言進行程式設計。全書貫徹了“用示例學習”的概念。在深入介紹了C語言的每個特性之後,給出了一個完整的示例程式,用於演示說明其套用。每章末尾的“案例學習”不僅介紹了把C語言的特性集成在一起的常用方法,而且還顯示了它在實際生活中的套用。最後一章介紹了開發高效、無錯誤的C程式的一些指導原則。
本書在前一版的基礎上增加介紹了C99的一些新特性,並增加了不少複習題和項目設計題,而且在附錄IV中給出了4個完整的應用程式開發示例,使得本書的實際套用性更強。
圖書目錄
PrefacetotheFourthEditionxi
lacetotheFourthEditionxi
1OverviewofC1
1.1HistoryofC1
1.2ImportanceofC3
1.3SampleProgram1:PrintingaMessage3
1.4SampleProgram2:AddingTwoNumbers6
1.5SampleProgram3:InterestCalculation8
1.6SampleProgram4:UseofSubroutines10
1.7SampleProgram5:UseofMathFunctions11
1.8BasicStructureofCPrograms12
1.9ProgrammingStyle14
1.10Executinga'C'Program14
1.11UnixSystem16
1.12Ms-DosSystem18
ReviewQuestions19
ProgrammingExercises20
2Constants,Variables,andDataTypes23
2.1Introduction23
2.2CharacterSet23
2.3CTokens25
2.4KeyWordsandidentifiers25
ywordsandldentiners25
2.5Constants26
2.6Variables30
2.7DataTypes31
~'
2.8DeclarationofVariables34
2.9DeclarationofStorageClass37
2.10AssigningValuestoVariables38
2.11DefiningSymbolicConstants44
2.12DeclaringaVariableasConstant45
2.13DeclaringaVariableasVolatile45
ViContents
2.14OverflowandUnderflowofData46
ReviewQuestions49
ProgrammingExercises51
3OperatorsandExpressions52
3.1Introduction52
3.2ArithmeticOperators52
3.3RelationalOperators55
3.4LogicalOperators57
3.5AssignmentOperators57
3.6IncrementandDecrementOperators59
3.7ConditionalOperator61
3.8BitwiseOperators61
3.9SpecialOperators61
3.10ArithmeticExpressions63
3.11EvaluationofExpressions64
3.12PrecedenceofArithmeticOperators65
3.13SomeComputationalProblems67
3.14TypeConversionsinExpressions68
3.15OperatorPrecedenceandAssociativity72
3.16MathematicalFunctions74
ReviewQuestions78
ProgrammingExercises81
4ManaginginputandOutputOperations84
4.1Introduction84
4.2ReadingaCharacter85
4.3WritingaCharacter88
4.4Formattedinput89
4.5FormattedOutput98
ReviewQuestions110
ProgrammingExercises112
5DecisionMakingandBranching114
5.1Introduction114
5.2DecisionMakingwithiFStatement114
5.3SimpleiFStatement115
5.4TheIF.....ELSEStatement119
5.5NestingofIF....ELSEStatements122
5.6TheELSEIFLadder126
5.7TheSwitchStatement129
5.8The?'Operator133
5.9TheGOTOStatement136
ReviewQuestions144
ProgrammingExercises148
ContentsVii
6DecisionMakingandLooping152
6.1Introduction152
6.2TheWHILEStatement154
6.3TheDOStatement157
6.4TheFORStatement159
6.5JumpsinLOOPS166
6.6ConciseTestExpressions174
ReviewQuestions182
ProgrammingExercises186
7Arrays190
7.1Introduction190
7.2One-dimensionalArrays192
7.3DeclarationofOne-dimensionalArrays193
7.4InitializationofOne-dimensionalArrays195
7.5Two-dimensionalArrays199
7.6InitializingTwo-dimensionalArrays204
7.7Multi-dimensionalArrays208
7.8DynamicArrays209
7.9MoreaboutArrays209
ReviewQuestions223
ProgrammingExercises225
8CharacterArraysandStrings229
8.1Introduction229
8.2DeclaringandinitializingStringVariables230
8.3ReadingStringsfromTerminal231
8.4WritingStringstoScreen236
8.5ArithmeticOperationsonCharacters241
8.6PuttingStringsTogether242
8.7ComparisonofTwoStrings244
8.8String-handlingFunctions244
8.9TableofStrings250
8.10OtherFeaturesofStrings252
ReviewQuestions257
ProgrammingExercises259
9User-definedFunctions262
9.1Introduction262
9.2NeedforUser-definedFunctions262
9.3AMulti-functionProgram263
9.4ElementsofUser-definedFunctions266
9.5DefinitionofFunctions267
9.6ReturnValuesandtheirTypes269
9.7FunctionCalls270
9.8FunctionDeclaration272
VinContents
9.9CategoryofFunctions274
9.10NoArgumentsandnoReturnValues274
9.11ArgumentsbutnoReturnValues277
9.12ArgumentswithReturnValues280
9.13NoArgumentsbutReturnsaValue284
9.14FunctionsthatReturnMultipleValues285
9.15NestingofFunctions286
9.16Recursion288
9.17PassingArraystoFunctions289
9.18PassingStringstoFunctions294
9.19TheScope,VisibilityandLifetimeofVariables295
9.20MultifilePrograms305
ReviewQuestions311
ProgrammingExercises315
10StructuresandUnions317
10.1Introduction317
10.2DefiningaStructure317
10.3DeclaringStructureVariables319
10.4AccessingStructureMembers321
10.5Structureinitialization322
10.6CopyingandComparingStructureVariables324
10.7OperationsonindividualMembers326
10.8ArraysofStructures327
10.9ArrayswithinStructures329
10.10StructureswithinStructures331
10.11StructuresandFunctions333
10.12Unions335
10.13SizeofStructures337
10.14BitFields337
ReviewQuestions344
ProgrammingExercises348
11Pointers351
11.1Introduction351
11.2UnderstandingPointers351
11.3AccessingtheAddressofaVariable354
11.4DeclaringPointerVariables355
11.5InitializationofPointerVariables356
11.6AccessingaVariablethroughitsPointer358
11.7ChainofPointers360
11.8PointerExpressions361
11.9PointerincrementsandScaleFactor362
11.10PointersandArrays364
11.11PointersandCharacterStrings367
11.12ArrayofPointers369
ContentsiX
11.13PointersasFunctionArguments370
11.14FunctionsReturningPointers373
11.15PointerstoFunctions373
11.16PointersandStructures376
11.17TroubleswithPointers379
ReviewQuestions385
ProgrammingExercises388
12FileManagementinC389
12.1Introduction389
12.2DefiningandOpeningaFile390
12.3ClosingaFile391
12.4Input/OutputOperationsonFiles392
12.5ErrorHandlingDuringI/OOperations398
12.6RandomAccesstoFiles400
12.7CommandLineArguments405
ReviewQuestions408
ProgrammingExercises409
13DynamicMemoryAllocationandLinkedLists411
13.1Introduction411
13.2DynamicMemoryAllocation411
13.3AllocatingaBlockofMemory:MALLOC413
13.4AllocatingMultipleBlocksofMemory:CALLOC415
13.5ReleasingtheUsedSpace:Free415
13.6AlteringtheSizeofaBlock'REALLOC416
13.7ConceptsofLinkedLists417
13.8AdvantagesofLinkedLists420
13.9TypesofLinkedLists421
13.10PointersRevisited422
13.11CreatingaLinkedList424
13.12Insertinganitem428
13.13Deletinganitem431
13.14ApplicationofLinkedLists433
ReviewQuestions440
ProgrammingExercises442
14ThePreprocessor444
14.1Introduction444
14.2MacroSubstitution445
14.3Fileinclusion449
14.4CompilerControlDirectives450
14.5ANSIAdditions453
ReviewQuestions456
ProgrammingExercises457
XContents
15DevelopingaCProgram:SomeGuidelines458
15.1Introduction458
15.2ProgramDesign458
15.3ProgramCoding460
15.4CommonProgrammingErrors462
15.5ProgramTestingandDebugging469
15.6ProgramEfficiency471
ReviewQuestions472
Appendixi:Bit-levelProgramming474
AppendixII:ASCllValuesofCharacters480
Appendixill:ANSICLibraryFunctions482
AppendixIV:Projects486
AppendixV:C99Features537
Bibliography545