开发工具:
文件大小: 371kb
下载次数: 0
上传时间: 2011-06-20
详细说明: C Programming.pdf Contents Computers 1 An Introduction to Computers........................................................................................1 Hardware and Software ....................................................................................1 Data and Information .......................................................................................2 Data Processing................................................................................................2 Programming Languages 4 What is Programming? . .................................................................................................4 From Problem to Program ................................................................................5 Programming Languages ...............................................................................................8 C 8 A look at C ....................................................................................................................8 Making C Run..................................................................................................9 Creating C Programs........................................................................................9 What Comprises a C Program?.......................................................................10 The Advantages of C ......................................................................................11 The Disadvantages of C..................................................................................11 A First C Program 11 The Program Example .................................................................................................11 #include ........................................................................................................12 .......................................................................................................12 void ...............................................................................................................12 main ..............................................................................................................13 ( void )...........................................................................................................13 { .....................................................................................................................13 float ...............................................................................................................13 height, width, area, wood_length................................................................13 ; .....................................................................................................................14 scanf .............................................................................................................14 ( .....................................................................................................................14 "%f", ..............................................................................................................14 &height..........................................................................................................15 ) ; ...................................................................................................................15 scanf ( "%f", &width ) ;.................................................................................15 area = 2 * height * width ;............................................................................15 wood_length = 2 * ( height + width ) * 3.25 ;.................................................16 printf..............................................................................................................16 ( "The area of glass needed is : %f metres.\n",.........................................16 area ) ; ..........................................................................................................17 printf ( "The length of wood needed is : %f feet.\n", wood_length ) ; ......17 } .....................................................................................................................17 Punctuation ....................................................................................................17 Variables 18 ii Variables and Data .........................................................................................18 Types of Variables .......................................................................................................18 Declaration ..................................................................................................................18 int variables....................................................................................................19 float variables ................................................................................................19 char variables ................................................................................................19 Missing Types ................................................................................................19 Variable Declaration ....................................................................................................19 Giving Values to Variables ..........................................................................................20 Expressions ....................................................................................................21 Types of Data in Expressions..........................................................................22 Getting Values into the Program ..................................................................................23 Writing a Program 24 Comments......................................................................................................24 Program Flow ..............................................................................................................24 Conditional Execution - if...............................................................................25 Conditions and Relational Operators ..............................................................26 Combining Logical Operators.........................................................................27 Lumping Code Together.................................................................................27 Magic Numbers and #define..........................................................................28 Loops .............................................................................................................29 Breaking Out of Loops ...................................................................................32 Going Back to the Top of a Loop ....................................................................32 More Complicated Decisions ..........................................................................33 Complete Glazing Program ............................................................................33 Operator Shorthand........................................................................................34 Statements and Values....................................................................................35 Neater Printing...............................................................................................36 Functions 37 Functions So Far ..........................................................................................................37 Function Heading ...........................................................................................37 Function Body ................................................................................................38 return .............................................................................................................38 Calling a Function..........................................................................................38 Scope .............................................................................................................39 Variables Local to Blocks ...............................................................................40 Full Functions Example..................................................................................40 Pointers.......................................................................................................................42 NULL Pointers ...............................................................................................44 Pointers and Functions ...................................................................................44 Static Variables............................................................................................................45 Arrays 46 Why We Need Arrays ..................................................................................................46 Sorting ...........................................................................................................47 Array Types and Sizes..................................................................................................49 More Than One Dimension ............................................................................50 Switching 53 Making Multiple Decisions ..........................................................................................53 Strings 55 iii How long is a piece of string?.......................................................................................55 Putting Values into Strings ..........................................................................................56 Using Strings ...............................................................................................................57 The String Library .......................................................................................................58 strcpy .............................................................................................................59 strcmp ............................................................................................................59 strlen..............................................................................................................59 Reading and Printing Strings .......................................................................................59 Bomb Proof Input.........................................................................................................60 Structures 61 What is a Structure?.....................................................................................................61 How Structures Work...................................................................................................63 Pointers to structures....................................................................................................63 Defining your own Types .............................................................................................64 Files 65 When do we use Files? .................................................................................................65 Streams and Files ...........................................................................................65 fopen and fclose ...........................................................................................................66 Mode String ...................................................................................................68 File Functions ..............................................................................................................70 fread and fwrite ..............................................................................................70 The End of the File and Errors.....................................................................................71 Memory 72 Fetching Memory.........................................................................................................72 malloc ............................................................................................................72 free.................................................................................................................73 The heap......................................................................................................................73 C and Large Programs 74 Building Large Programs in C .....................................................................................74 The Compile and Link Process .......................................................................74 Referring to External Items ............................................................................75 The Make Program.........................................................................................76 Projects ..........................................................................................................76 The C Pre-Processor.....................................................................................................77 The #include Directive ...................................................................................77 Conditional Compilation ................................................................................77 A Sample Project .........................................................................................................78 The Problem...................................................................................................78 The Data Structure .........................................................................................78 Program Files.................................................................................................79 The Most Important Bit!.................................................................................84 Glossary of Terms 93 ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.