C Language notes, C Language notes

Source: Internet
Author: User

C Language notes, C Language notes

Below I will post some C Language notes I have written over the past six months.

1 in C language, function parameters are transmitted according to "value transfer", that is, one-way transmission.

2. function prototype: Function Name of the function type (parameter type, parameter type ......), You do not need to add a parameter name because the operating system does not check the parameter name.

3. The array is passed as the real parameter. If the type parameter is also an array declaration, the array size can be not specified in the first dimension. At this time, the array has been degraded to a pointer. Therefore, the array length must be received in the parameter. When a parameter group name is referenced locally, it is not an array but a pointer.

4. function definitions cannot be nested.

The array definition in parameter 5 does not specify the size of a one-dimensional array. The C compiler does not check the size of the parameter group, but only transmits the first address of the real parameter array to the parameter group. Therefore, the pointers of the two array names are consistent. The two arrays occupy a memory unit. For array names, the size of one-dimensional arrays can be ignored, but the two-dimensional and high-dimensional size declarations cannot be ignored. The C compiler does not check the size of the First-dimensional array.

6. Dynamic Storage and static storage: static storage refers to the way in which fixed storage space is allocated during the program running, and dynamic storage dynamically allocates and manages the storage space as needed. Global variables are stored in the static storage area, as are static local variables. The global variables declared using static indicate that the scope is only in this file, and cannot be referenced by other files after being declared using "extern". The same static function.

7. Only local variables and type parameters can be used as register variables. Don't ask why, just think for yourself!

8. Use "extern" to declare external variables. during compilation, the external variables are allocated in the static storage area.

9. Use "extern" to declare an external variable, which may be in this document. The applicable situation is "the application is located before the Declaration ". Or in other files: extern int a; or extern a; search first in this file, then external files.

10 pre-processing commands, which are not part of the C language.

11 a [I] is the same as * (a + I), while internal processing converts a [I] To * (a + I );

12 constructor methods in java cannot inherit from the quilt class. If the subclass needs to call the parent class's constructor method with parameters, the super () method must be used. The normal compiler automatically calls the non-argument constructor of the parent class. Displays members in the super () parent class.

13 The first statement of the constructor in java can be called this, that is, other constructor methods can be called by applying the this parameter.

14 C language data types can be roughly divided into four types: Basic Types (integer, struct type, real type, enumeration type), construction type (array, struct type, shared body), pointer type, null type.

15 The maximum value of an int type variable in Turbo C is 32767. If you add 1 to it, it will overflow and change to-32768.

16 if an integer constant is followed by a letter, u or U, it is considered to be unsigned int type. For example, 12345u is stored in the computer according to the unsigned int. The highest bit in a storage unit is used to store data instead of a signed bit. If the number is 123L, it indicates long int.

17 float 4 bytes, valid digits 6-7. Double is 8 bytes, with a valid number of 15-16 digits.

18 rounding error of real data. % F is the format character for outputting a real number. See the following program:

Main ()
{
Float a, B;
A = 123456.789e5;
B = 2 + 20;
Printf ("% f", B );
}

Real variables can only ensure 7 valid digits. The following digits are meaningless and inaccurate. The output values a and B are both 12345678848.000000. Similarly, if 1.0/3*3 is output, the output is not equal to 1.

Real constants, C compilation system for double precision processing.

19 if I = 3, printf ("% d",-I ++), take the post auto-increment of I first, return result 3, and then take negative, although the output is-3, I is 4.

20. Benefits of the variable "first defined and then used" principle: ensure that the program variable name is correctly used, the type is determined, and corresponding storage units can be allocated to it during compilation; it is conducive to checking the validity of computation during compilation.

21 if float a = 4.5; then (int) a/1.5 results in 2.66 ...... Instead of 3, this indicates that the Operation Sequence first converts the type before division.

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.