Notes on C Language Learning

Source: Internet
Author: User

Chapter 1 Overview
1. Features of C Language
① The language is concise, compact, easy to use, and flexible. There are 32 keywords and 9 control statements.
② Rich operators, 34 types of public operators.
③ Rich data structures: integer, real, String, array, pointer, struct, and shared body.
④ Structured control statements (such as if... Else, while, do... While, switch,)
⑤ Syntax restrictions are not strict, and the degree of freedom in programming is large.
⑥ Allow direct access to the physical address, bit operations, and direct hardware operations.
7. The quality of the generated target code is high, and the program execution efficiency is high.
Strong portability.
2. Use of C Language
C is not good at scientific computing and management, but it operates operating systems, system utilities, and hardware,
C has obvious advantages. Many large applications are also written in C.
Top of Page
Chapter 2 data types, operators and expressions
1. C Data Type
The Data Types of C include: integer, numeric, real, or floating point (single-precision and double-precision), enumeration, array
Type, struct type, shared body type, pointer type, and null type.
2. constants and variables
The value of a constant cannot be changed, and the symbolic constant name is usually capitalized. The value of a variable can be changed. The variable name can only contain letters and numbers.
And underscores (_). The first character must be a letter or underscore. Otherwise, the variable name is invalid. Variable Compilation
Allocate storage units to them.
3. Integer Data
The expression of an integer constant: Needless to say, it must start with 0 in decimal format, such as 0123. The hexadecimal format starts with 0x, as shown in figure
0x1e.
Integer variables include: basic type (int), short type (short int), long type (long int), and unsigned type. Different machines
The memory size of various types of data on the device is different. Generally, the int type is 2 bytes, and the long type is 4 bytes.
4. Real Data
Real-type constant representation: the decimal form consists of digits and decimal points (must have decimal points), such as: 0.12,. 123, 123
0.0. For example, 123e3 represents the 3rd power of 123x10.
Real variables are classified into two types: Single-precision (float) and double-precision (double. In general, the float type occupies 4 bytes and 7 digits.
Valid number. double represents 8 bytes, 15 ~ A 16-digit valid number.
5. Balanced data
Character variables are enclosed in single quotes, such as ''a' and ''B. There are also some special character constants, such as ''n'' and ''t. Representatives respectively
Line feed and horizontal hop.
Character variables are defined by char. A variable can only store one character constant.
String constants are character sequences enclosed by double quotation marks. Note the differences between ''a' and "a". The former is a character
The latter is a String constant. c stipulates that an ending sign ''' is added to the end of each string. In fact, "a" contains two
Characters: ''a' and ''''.
6. Mixed operation between numeric data
Integer, numeric, and real data can be operated in a hybrid manner. Different types of data must be converted to the same type before calculation,
Conversion rules:
Char, short-> int-> unsigned-> long-> double <-float
7. Operators and expressions
The c Operator includes:
Arithmetic Operator (+-*/%)
Relational operators (><=>=<=! =)
Logical operators (! & |)
Bitwise operators (<> ~ | ^ &)
Value assignment operator (=)
Conditional operators (? :)
Comma operator (,)
Pointer operator (*&)
Sizeof)
Forced type conversion (type)
Component operator (.->)
Subscript operator ([])
Other operators (such as function call operators ())
Note: note the differences between ++ I and I ++. Before using I, ++ I adds 1 and I ++ uses
After I, add I to 1.
The process of solving a comma-separated expression: first, first, then, expression 2. The value of the entire expression is the value of expression 2.
Value.
Top of Page
Chapter 3 simplest c Programming
9 control statements of 1. c:
If ()~ Else ~
For ()~
While ()~
Do ~ While ()
Continue
Break
Switch
Goto
Return
Three basic structures of a program: Sequence Structure, selection structure, and cyclic structure
2. Data Output
C language does not provide input and output statements. Input and Output operations are completed by c library functions. But it must contain the header file stdio. h.
Putchar () Outputs a character to the terminal
Printf () format characters:
① D is used to output a decimal integer.
% D output according to the actual length of Integer Data
% Md sets the output length to m. If the data length is smaller than m, spaces are left filled. If the output length is greater than m,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.