Current location - Quotes Website - Famous sayings - C language learning manual content
C language learning manual content
Chapter 65438 +0 Basic Chapter

Chapter 1 Meet C 16

1. 1 C language introduction 17

1. 1. 1 programming language introduction 17

1. 1.2 generation c language 18

Characteristics of 1. 1.3 C language 19

1.2 reasons for choosing C language 2 1

The development trend of 1.2. 1 C language

1.2.2 C language success story 23

Application fields of 1.2.3 C language 25

1.3 How to learn 25 well

1.3. 1 Establishing learning attitude 26

1.3.2 lay a solid foundation 26

1.3.3 Ask more questions and communicate more 26

1.3.4 Develop good programming habits 27

1.3.5 think more about it.

1.3.6 mastering learning methods 27

1.4 Summary of this chapter 28

The second chapter C language programming preparation 29

2. 1 programming format 30

A simple c program

2. 1.2 identifiers and keywords 34

2.2 Development environment 37

2.2. 1 Turbo C 2.0 38

Visual C++ 6.0 42

2.3 A complete C program 48

2.4 Practice Exercise 52

2.4. 1 Write a simple C program 52

2.4.2 Familiar with development tools 53

2.5 Overview of this chapter 53

Chapter III The Soul of C Language-Algorithm 54

3. 1 Basic concept of algorithm 55

3. 1. 1 Features of the algorithm 55

3. Advantages and disadvantages of1.2 algorithm 57

3.2 Describe Algorithm 57

3.2. 1 natural language 58

3.2.2 Describe the flow chart 58

Draw N-S flow chart 64

Pseudo code 68

3.3 Overview of this chapter 69

Chapter 4 Constants and Variables 70

4. 1 Understanding data type 7 1

4.2 Interpretation of Constant 72

4.2. 1 integer constant 72

4.2.2 Real constant 75

4.2.3 Character constant 76

4.2.4 escape character 80

Symbolic constant 8 1

4.2.6 scene application 1: output "I love c" 82 with putchar function.

4.2.7 Scenario Application 2: printf function combined with escape character 83

4.3 Variables 83

4.3. 1 integer variable 84

4.3.2 Scenario Application: Find out the total amount spent on buying fruit 86

Real variable 87

4.3.4 Character variables 89

4.4 Master the mixing operation 9 1

4.5 actual combat exercises 93

4.5. 1 Use printf statement to output variable 93

4.5.2 Using Character Variables to Output String 94

4.6 Overview of this chapter 94

Chapter 5 Expressions and Operators 95

5. Interpretation of1expression 96

5.2 Assignment Operators and Assignment Expressions 98

A variable with an initial value of 98

5.2.2 Automatic type conversion 100

5.2.3 Forced type conversion 100

5.3 Master arithmetic operators and expressions 102

5.3. 1 arithmetic operator 102

5.3.2 Arithmetic expression 102

5.3.3 Priority and combination 104

5.3.4 Self-increasing and Self-decreasing Operator 105

5.3.5 Scenario application: Find the values of four variables after operation, 107.

5.4 Understanding relational operators and expressions 108

5.4. 1 relational operator 108

5.4.2 relational expression 109

5.4.3 Priority and combination 1 10

5.5 Interpretation of logical operators and expressions 1 1 1

5.5. 1 logical operator11/

Logical expression 1 12

5.5.3 Priority and combination 1 12

5.6 Use bitwise logical operators and the expression 1 13.

5.6. 1 bitwise logical operator 1 14

5.6.2 Bit Logical Expression 1 14

5.7 Introduce comma operator and expression 1 14.

5.8 Use the compound assignment operator 1 16.

5.9 Judgment condition operator 1 17

5. 10 Understanding the priority and combination of operators 1 18

5. 1 1 practical exercise 1 19

5. 1 1. 1 Find the calculation result with compound assignment operator 1 19.

5. 1 1.2 Find the calculation result of 120 with the self-increasing and self-decreasing operator.

5. 1 1.3 Write a simple program for calculating overtime pay 12 1.

5. 12 Overview of this chapter 122

Chapter VI Input and Output Functions 123

6. 1 explanation statement 124

6. 1. 1 expression statement 124

6. 1.2 empty sentence 124

6. 1.3 composite report 124

6.2 Input and output character data 125

6.2. 1 output character data 125

6.2.2 Input character data 126

6.2.3 Scenario application: use the getchar function to cancel obtaining the Entet key 127.

6.3 Input and output strings 128

6.3. 1 Use string output function 128.

6.3.2 Mastering the function of string input 130.

6.4 Introduce the format output function 13 1

6.5 Interpretation of format input function 134

6.6 Application Sequence Programming 138

6.7 Practice 14 1

6.7. 1 Convert input lowercase characters into uppercase characters 14 1.

6.7.2 Simulated Salary Calculator 142

6.7.3 Input and output the old saying 142.

6.8 Overview of this chapter 143

Chapter 7 Select Structure Programming 144

7. 1 if choice statement 145

7.2 DIFferent forms of if statements 145

7.2. 1 single conditional single branch if statement 146

7.2.2 Single conditional double-branch if statement 149

7.2.3 Multi-conditional multi-branch if statement 153

7.2.4 Scenario application: Enter the character type of numerical check 156.

7.3 master the nested form of if statement 157

7.4 Pay attention to the common mistakes of if statement 160.

7.4. 1 Precautions for using semicolons

7.4.2 Precautions for Conditional Placement 16 1

7.4.3 Matters needing attention in pairing if and else 162

Importance of support 162

7.5 Judgment Branch Selection Switch Statement 163

7.5. Basic form of1switch statement 163

7.5.2 Switching statement of multi-channel switching mode 167

7.6 Distinguish if…else statement from switch statement 169

7.7 Apply the selection structure program 17 1

7.8 Practice 173

7.8. 1 Calculate the function and get the value of y 173.

7.8.2 Output the maximum number of three variables, 174.

7.8.3 Calculate the increased salary 175.

7.9 Overview of this chapter 175

Chapter 8 Loop statement 176

8. 1 Writing Loop Statements 177

8.2 execute while loop 177

8.2. General form of1while loop statement 178

8.2.2 Scenario application: Find the sum of all positive integers in the value 180.

8.2.3 Avoid infinite loop of while loop statement 182.

8.2.4 Understanding the empty loop body of the while loop statement 183

8.2.5 Pay attention to the common error 183 in the while loop statement.

8.3 Interpretation of the for loop statement 185

8.3. General form of1for loop statement 185

8.3.2 Flexible for loop statement 189

8.3.3 Use comma 192 in the for statement.

8.4 Introduce the do-while statement 193.

8.5 Compare three cycles 195

8.6 Use circular nesting 195

8.6. 1 cyclic nesting of various structures 195

8.6.2 Loop Nested Instance 197

8.7 Transfer Statement 199

8.7. 1 Go to statement 200

8.7.2 Interrupt Statement 202

8.7.3 Continue the presentation 203

8.8 Distinguish three kinds of jump statements 205

8.9 Practice Exercise 205

8.9. 1 Print out the ASCII code comparison table with capital letter 205.

8.9.2 Print out the ASCII code comparison table of lowercase letters 206.

8.9.3 Output the number 207 between 0 and 100, which is not divisible by 3.

8. 10 Summary of this chapter 209

The second core article

Chapter 9 Array 2 12

9. 1 introduces the concept of array 2 13.

Classification 9. 1. 1 array213

9. Dimension of1.2 array 2 13

9.2 Application of one-dimensional array 2 14

9.2. 1 one-dimensional array definition 2 14

9.2.2 One-dimensional array reference 2 15

9.2.3 Initialization of one-dimensional array 2 17

9.2.4 Application of one-dimensional array220

9.3 Main 2D Array 222

9.3. 1 Definition of two-dimensional array 222

9.3.2 References to two-dimensional arrays 223

Initialization of 2D Arrays 223

Application of two-dimensional array 227

9.4 Interpretation of Multidimensional Arrays 228

9.5 Using Character Array 229

9.5. 1 character array definition 229

9.5.2 Reference Character Array 229

Initialization of character array 229

9.5.4 End mark of character array 23 1

9.5.5 Output of Character Array232

9.5.6 Input of Character Array 233

9.5.7 Output a complete string containing spaces 234.

Application of character array 235

9.6 string processing function 236

9.6. Copy of1string 237

9.6.2 String concatenation 238

9.6.3 String comparison 240

9.6.4 String case conversion 24 1

9.6.5 Get the Length of String 243

9.7 Skilled application of array 245

9.7. 1 Reverse Output String 245

9.7.2 Using arrays to calculate student scores 246

9.7.3 Scenario Application: Encryption and Decryption of String 248

9.8 Exercise 250

9.8. 1 Realize the function of strcpy function 250

9.8.2 Calculate the number of elements in a character 25 1.

9.8.3 Reorder the string 25 1

9.9 Overview of this chapter 252

Chapter 10 Function 253

10. 1 function overview 254

10.2 defines function 256

10.2. 1 function definition table 256

10.2.2 definition and declaration

10.3 Understanding the Return Form 262

10.3. 1 function returns 262.

10.3.2 return value 266

10.4 transfer function parameter 269

10.4. 1 formal parameters and actual parameters 269

10.4.2 array as function parameter 27 1.

10.4.3 Understand the parameters of master 276.

10.5 calls function 276.

10.5. 1 function calling method 277

10.5.2 nested call 280

10.5.3 Recursively call 282

10.6 Flexible application functions 285

On the application of the function 10.6. 1 20000.100000000606

10.6.2 scenario application: use character function to judge input character 290.

10.7 exercise and exercise 292

10.7. 1 output a larger integer of 292.

10.7.2 Find the average score of 10 students.

10.7.3 Verification 6 174 293

10.8 Summary of this chapter 294

Chapter 1 1 pointer 296

1 1. 1 Understand the related concepts of pointer 297

11.1.1Introduction address and pointer 297

1 1. 1.2 Interpreting variables and pointers 298

1 1. 1.3 uses the pointer variable 299.

1 1. 1.4 pointer addition and subtraction operation 303

1 1. 1.5 scenario application: output integer variable address 304.

1 1.2 control array and pointer 305

1 1.2. 1 one-dimensional array and pointer 306

1 1.2.2 scene application 1: output array element 309

1 1.2.3 2D array and pointer 3 10

1 1.2.4 scenario application 2: put a two-dimensional array with 3 rows and 5 columns.

The second line element output 3 13

String and pointer 3 14

1 1.2.6 String Array316

1 1.3 pointer to pointer 3 18

1 1.3. 1 application introduction pointer points to pointer 3 18

1 1.3.2 scenario application: output even number 320.

1 1.4 pointer variable 32 1 as the function parameter.

1 1.5 returns the function of pointer value 33 1

1 1.5. 1 introduces the function 33 1 that returns the pointer value.

1 1.5.2 scene application: find the perimeter of the rectangle 332

1 1.6 pointer array as parameter 333 of the main function.

1 1.7 actual combat exercise 335

1 1.7. 1 stores the element values in the array in reverse order.

1 1.7.2 concatenates two strings and outputs 336.

1 1.7.3 Copy the string 336 with a pointer.

1 1.8 Summary of this chapter 337

Chapter 12 structure and community 338

12. 1 application structure 339

12. 1. 1 the concept of structure type 339

Definition of structural variables 340

12. 1.3 references structure variable 342.

12. 1.4 structure type 344 initialization

12. 1.5 Scenario Application: Output Student Information 345

12.2 main structure array 348

12.2. 1 defines the structure array 348.

12.2.2 Initializes the structure array 349

12.2.3 Scenario Application: Output Student Information 35 1

12.3 Interpreting structure pointer 353

12.3. 1 pointer to structure variable 353

Pointer to structure array 356

12.3.3 structure as functional parameter 358

12.4 introduces a structure containing structure 360.

12.5 Application Community 362

12.5. 1 the concept of commons 362

12.5.2 general body variable reference 363

12.5.3 initialization of public volume variables 364

12.5.4 Data characteristics of common body types 365

12.6 explanation of enumeration type 365

Practice exercise 366

Count the votes of candidates

12.7.2 teacher-student information storage system 367

12.7.3 Calculate students' comprehensive scores 368

12.8 Summary of this chapter 368

Chapter 13 Linked list and algorithm 369

13. 1 list introduction 370

13. 1. 1 list overview 370

Create a dynamic linked list 37 1

13. 1.3 output linked list 374

13.2 performs related operation 376 on the linked list.

13.2. 1 Insert operation of linked list 377

Delete operation of 13.2.2 linked list 380

13.3 uses array sorting algorithm 384.

1 select sort 385

13.3.2 bubble sorting 387

13.3.3 exchange method ranking 389

Insert sort 39 1

13.3.5 Sort by half method 394

13.3.6 comparison array sorting algorithm 396

13.4 Practice Exercise 397

13.4. 1 Delete operation of linked list 397

13.4.2 Sorting by Selection Method 398

13.4.3 Sort by bubbling, exchange, insertion, half folding, etc. 399

13.5 Section 399 of this chapter

The third advanced article

Chapter 65438 +04 operation 402

14. 1 interpretation bits and bytes 403

14.2 main bitwise operation operator 403

14.2. 1 and operator 404

14.2.2 or operator 405

14.2.3 NOT operator 407

14.2.4 XOR operator 409

14.2.5 "move left" operator 4 12

14.2.6 "Move Right" Operator 4 13

14.2.7 bit operation compound assignment operator 4 15

14.2.8 bit manipulation of data with different lengths 4 15

14.3 cyclic shift 4 16

14.4 What is the bit field 4 18?

The concept and definition of 14.4. 1 bit field 4 19

14.4.2 bit field 420 description

14.5 practical exercises 42 1

14.5. 1 The result of AND and OR operation on two numbers is 42 1.

14.5.2 Find the result of "left shift" and "right shift" of a number 422.

14.5.3 Find the result of a number "cyclic left shift" and "cyclic right shift" 422.

14.6 Summary of this chapter 423

Chapter 15 Warehouse Management 424

15. 1 memory organization mode 425

15. 1. 1 organization for understanding memory 425

Interpretation of Heaps and Stacks 425

15.2 dynamic management 428

15.2. 1 dynamically allocate memory space -malloc function 428

15.2.2 Dynamic allocation of continuous memory space array -Calloc function 429

15.2.3 change the size of the ptr pointer -Realloc function 43 1

15.2.4 Scenario Application: realloc function is used to reallocate memory 432.

15.2.5-Release function 432 to release the memory space allocated for integer variables.

Memory loss 433

15.4 storage category of variables 434

15.4. 1 dynamic storage and static storage.50000.00000000015

15.4.2 change local variable to automatic variable 435.

15.4.3 Declare static variable 436 with different positions and meanings.

15.4.4 register storage class register variable 437

15.4.5 External storage of external variables 437

15.5 Practice Exercise 438

15.5. 1 dynamically allocate array memory 438

15.5.2 Free memory for array dynamic allocation 439.

15.5.3 Calculate the square sum cube of 3 with static local integer variables.

15.6 Summary of this chapter 440

Chapter 16 Function Types and Pretreatment 44 1

16. 1 internal and external functions 442

16. 1. 1 introduction to internal functions 442

16. 1.2 Interpretation of external functions 443

Flexible use of macro definitions in 16.2 444

16.2. 1 macro definition without parameters 445

16.2.2 Macro definition with parameters 446

16.3 writing # contains instruction 448.

16.4 Compiling with Conditions 450

16.4. 1 #if command 450

16.4.2 #ifdef and #ifndef command 453

16.4.3 #undef command 455

16. 4. 4 # line command 455

16. 4. 5 # miscellaneous note command 456

Exercise 457

16.5. 1 Find the product of multiplying two numbers 457.

16.5.2 Find the smallest number from three numbers 457.

16.5.3 Find the maximum number 458 from three numbers.

16.6 Summary of this chapter 459

Chapter 17 Reading and writing files 460

Document overview 46 1

17.2 master the basic operation of files 462

17.3 using file pointer 463

17.4 opening and closing files 464

17.4. 1 file open464

Closure of files

17.5 read and write files 466

17.5. 1 write character function -FPUTC function 466

17.5.2 character reading function -FGETC function 468

17.5.3 Write string function -fputs function 469

17.5.4 read string function -FGETS function 470

17.5.5 format writing function -FPRINTF function 472

17.5.6 format reading function -fscanf function 474

17.5.7 block reading and writing functions -Fread function and fwrite function 475

17.6 location file 478

17.6. 1 random read-write operation -fseek function 479

17.6.2 returns the position pointer rewind function 48 1

17.6.3 ftell function 483

Exercise 485

17. 7. 1 copy file contents 485

17.7.2 Save student information 486

17.8 Summary of this chapter 487

Article 4 actual combat articles

Chapter 18 Student Management System 490

18. 1 analysis requirements 49 1

18.2 design system 49 1

18.3 function module design 492

18.3. 1 function selection interface 492

18.3.2 student achievement information entry 494

18.3.3 Inquiring about student achievement information 496

18.3.4 Delete student achievement information 497

18.3.5 Modify the student achievement information 499

18.3.6 Insert student achievement information 50 1

18.3.7 Statistics on the number of students 504

18.4 Summary of this chapter 505

Appendix a glossary of technical terms 506