C language _ First speaking _c language introduction

Source: Internet
Author: User

The 1.C language is a standard, and the automation program generated when the standard is executed is the compiler
2. Understanding: The United States National Standardization Rest (ANSI) in 1983 developed the C language standard.
Features of the C language:
3. Code portability (ideally, the code can be ported without modification, provided that no platform-related libraries are included)
4. It is best to separate the business logic layer from the UI layer when writing code. This facilitates the porting of code
5. Structured programming (the problem can be decomposed into one function to execute)
6. Rich data types (rich in comparison to compilations)
7. Simple and efficient code (this depends on the person, not the compiler or language characteristics, if the algorithm does not write well, the same slow execution, and language-independent. Vice versa);

Ii. the ratio between code and debugging

1. The time scale for debugging and writing code is 2:8
2. Write code 2 debug time accounted for 8
3.UI and logical separation, UI accounted for 7, logic accounted for 2

Third, the dual use of & symbols

1. Symbols in the C language of the scene is not the same, then there will be different role
2. Columns such as:
3.++ + + 2 Plus is not the same as a plus
The 4.+ can be seen as a plus or a mathematical ± symbol.
5. So what operators can play a different role in various scenarios
The 6.& operation can be considered as the address symbol when used alone, if there is an operand on the left, it can be regarded as a bit and a symbol.


Iv. three representations of the suspended state of the program


1.Getchar ()
2.SCANF ("%d");
3.System ("pause");
4. Where system () is a platform-related function, so adding this sentence is not a cross-platform.

Five, scanf of common problems analysis

1.SCANF usage: Input into the program via standard input device
2. The second parameter-type address variable, is the address of the place. No address will take the value inside the variable as an address.
3. Error when accessing an address that should not be accessed
4. There are two useful information, respectively:
5. Exception code: c00005 means access to an address that should not be accessed
6. Unusually inexpensive: 00026 You can navigate to the location where the code went wrong
Summary: If you do not fill the address house, the program will not crash then may be a disadvantage, the program is affected
If the value of the variable is no longer initialized then the value remaining after the last memory use will be used
So be sure to initialize the variables.

Vi. Batch Processing

Del *.exe Delete all exe executable files in directory
Del *.obj Delete all the. obj files in the directory
CL/C/w4/wx file name. C Compile file name. C is the obj file
Link file name. obj connection file name. obj file name:. exe executable file
filename. exe to run the executable file
Pause pauses the window for further action

Seven, floating point number

View of floating-point numbers
1. The floating-point number is followed by an F column such as 3.25f for a floating-point number
2. If not, then the default will be considered a double-precision decimal
Zero 0 usage on different occasions
Char ch = ' + ';
Int n = 0;
Int *p = NULL;
Float f = 0.0f;
Double db = 0.0;
Remember the specifications of the software
Algorithms for converting decimals into 16 binary
1. First step: converting decimals to Binary
Let's say a decimal is 4.25.
Then the first conversion to binary is: 100.01
2. Step Two:
Position the decimal point at the back of the top 1 until it encounters a value of 1 for the first digit
So now it's 1.0001 to the left, 2 bits, so you can be seen as a 1.0001*2^2.
3. Step three: Define symbol bits
Sign bit 0, because 4.25 is a positive number
4. Fourth step: Define the exponent as (exponent is 11 bits for 8 bits under 32-bit system)
And the digit is the power of the 2^2 +127 his sub-square (that is, power) is 2
So that's 2+127 = 129
Conversion to binary is 1000 0001 the last plus sign bit is
0 1000 0001
5. Fifth step: Determine the mantissa as (the number of digits in the 23-bit insufficient 0 in)
Just put the 1.0001 front 1 off and put it in the back of the index.
0 1000 0001 0001 0000 0000 0000 0000 000

Finally, we convert from right-to-left 4-bit split binary to 16 binary.
0100 0000 1000 1000 0000 0000 0000 0000
4 0 8 8 0 0 0 0
According to the small end mode is 00 00 88 40

Implementation of hexadecimal conversion to decimal

First step: Convert the given hexadecimal to binary
44 22 00 00
0100 0100 0 010 0010 0000 0000 0000 0000
Second step: Remove the sign bit, take the digit (32 bit is 8 bit)
0 is the value after the sign bit is removed
1000 1000 128 +8 = 136
Step three: Subtract 127 from the exponent and then the mantissa from the front of the exponent plus 1 and then move to the right >> (the number of digits of the value from the exponent minus 127)
The result is 136-127 = 7; Then the decimal point is removed from the exponential position just now
The back of the 7-bit
The result is:
Note: After the index is removed, add a 1 point to the position after the exponent (1.XXX is the mantissa)
(When moving the position, it also starts from 1. Later)
1.010 0010 0000 0000 0000 0000 (I. 1. Not counting, moving from the mantissa
1 010 0010.0000 0000 0000 0000 (two. After moving
The fourth step: convert the results of the move to 10 binary number.
If the decimal place is then multiplied by 2^1 ... (The mantissa is multiplied by how much)
The correct result is: 16 binary of 162.00

C language _ First speaking _c language introduction

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.