-
Best selling package -
Selected Package -
Popularity package -
Exclusive package -
High salary package
-
Course Introduction -
Course outline
C language is very powerful
advantage
Very flexible and powerful Short and tough Concise language There are 32 keywords, 9 control statements, and free writing form
shortcoming
It is too flexible and has a large degree of programming freedom. It is difficult to get started Too many operator and operation priorities Not suitable for writing big things
C language standard
K&R C
In 1978, Dennis? Dennis Ritchie and Brian? Brian Kernighan co published the first edition of C Programming Language. The C language standard introduced in the book is also called "K&R C" by C language programmers The second edition of the book also contains some ANSI C standards. K&R C mainly introduces the following features: Structure type Long int type Unsigned int type Change the operators=+and=- to+=and -=. Because=+and=- will make the compiler not know whether the user needs to handle i=- 10 or i=- 10, which will cause confusion in processing. Even many years after the ANSI C standard was proposed, K&R C is still the minimum standard requirement for many compilers, and many old compilers still run the K&R C standard.
ANSI C, ISO C
The first standard of C was issued by ANSI. Although this document was later adopted by the International Organization for Standardization (ISO) and the revision issued by ISO was also adopted by ANSI, However, the name ANSI C (rather than ISO C) is still widely used. ANSI C is now supported by almost all widely used compilers. Now most C codes are written on the basis of ANSI C.
C89,C90
In 1983, the American National Standards Institute formed a committee, X3J11, to create a set of C standards. After a long and arduous process, this standard was completed in 1989 and officially took effect as ANSI X3.159-1989 "Programming Language C". This version of the language is often referred to as "ANSI C", or sometimes as "C89" (to distinguish C99). In 1990, the ANSI C standard (with some minor changes) was adopted as ISO/IEC 9899:1990 by the American National Standards Institute. This version is sometimes called C90 or ISO C. Therefore, C89 and C90 usually refer to the same language. Improvements from traditional C language to ANSI/ISO standard C language include: Added a true standard library New preprocessing commands and features Function prototypes allow specifying parameter types in function declarations Some new keywords, including const, volatile and signed wide characters, wide strings and byte multi characters Many minor changes and clarifications to the agreed rules, declarations and type checks
C99
In March 2000, ANSI adopted the ISO/IEC 9899:1999 standard. This standard usually refers to C99. C99 adds some features, such as: Support variable length arrays, that is, the array length can be determined at runtime. Variable declaration does not need to be placed at the beginning of the statement block. For statements are recommended to be written in the form of for (int i=0; i<100;++i), that is, i is only valid inside the for statement block. It is allowed to assign values to specific elements when initializing the structure. Allows the compiler to simplify non constant expressions. The requirement that the function return type defaults to int. However, different companies show different interest in C99 support. While GCC and other commercial compilers support most of the features of C99, Microsoft and Borland seem not interested in it, and they focus more on C++.
C11
In December 2011, ANSI adopted the ISO/IEC 9899:2011 standard. This standard is usually called C11, which is the * * standard of C programming language.
First program
How to start writing a program?
1. Objectives It is necessary to define the goal or effect that we want to achieve when writing this program, and think deeply about what we need to accomplish 2. Design Design our program in terms of ideas or ideas, and how to write the code. If necessary, use pseudo code 3. Start writing After the design is completed, start writing! 4. Test After writing, test the program, such as black box test, white box test, unit test Wait, wait, wait 5. Issuance The test is completed without problems, and the program is released 6. BUG modification After the release, there will be more people running, and there will definitely be bugs. We need to modify the bugs 7. Iterative update When more people run and use it for a long time, there will definitely be new requirements, so we need to update iteratively
matters needing attention
In C language, all punctuation marks (excluding the strings surrounded by English double quotation marks, that is, "...", but including placeholders and escape characters) are half width symbols
{...} represents the function body
Each item in the middle of the function body is a statement
In C language, statements usually end with the English semicolon ";" Of course, some are unnecessary, such as the for loop statement
A C language program must have one and only one main function (entry function)
Manual compilation
Environment: For Windows system, you need to install Visual Studio and open the "Developer Tools" command line provided by Visual Studio Of course, you can also set environment variables to achieve our goal Our only goal is to use "cl.exe"
Let's first write an ILoveHades c
Through our command line command: cl ILoveHades c
ILoveHades.obj will be generated after compilation
When the link is completed, ILoveHades.exe will be generated
Attention, our
The. obj file cannot be executed Of
Let's take a look at our implementation results:
Is there a sense of achievement!!!
Use of IDE
The IDE provides us with many conveniences For example: AutoComplete List Function parameter prompt One click compilation and running IntelliSense prompt Automatic completion Intelligent management of engineering documents ....
Rational use of IDE can greatly improve our development efficiency and quality
Code explanation
. c is our source code file, which we call "source file" . h makes our header file, which is used to summarize, equivalent to the directory of the corresponding source file, and contains various function declarations
#Include is a precompiled instruction and a step before compilation
The main function, the entry function, has one and only one
If there is no main function, compiling will not report an error, but when linking, the link1561 error will appear
From this we know that, Compilation is to check the syntax. After the check is passed, the obj file will be compiled Link, assemble our executable file, and detect various errors
Printf format
Attention required
Escape character Use of
Attention required
placeholder Use of. Please be sure to keep
The placeholder is consistent with the type of the given parameter .
four Program Compilation Process and Code Details Click "Only for paying users" to download "Lesson004 operation. txt" [11:40] Start learning five The first procedure is to summarize the homework and prepare for the next class Click "Only for paying users" to download "Lesson005 job. doc" [14:37] Start learning thirteen Click "Only for paying users" to download "Lesson013 statement task. docx" [28:36] Start learning fourteen Click "Only for paying users" to download "Lesson014 Job Precode FkTxGUI.7z" [33:22] Start learning fifteen Click "Only for paying users" to download "Lesson015 Branch Statement Operation. docx" [41:38] Start learning