C trivial knowledge points

Source: Internet
Author: User

1. singned char

The difference between signed Char/unsigned char mainly lies in char. The default value of char is signed or unsigned, which is related to the specific compiler. The default value of vc6.0 is signed.

2. You can view various float macro definitions in the float. h file of the include file.

3. octal 0123 and hexadecimal 0x123

4. Enum computer {

Lianxiang;

Daier;

Hongji;

};

Use Enum to define the value range of a constant, so that the computer value can only be in lianxiang daier hongji. If lianxiang is not initialized, the default initialization value is 0, followed by 1; if initialization starts from the daier, The daier is followed by 1 based on the initial value of the daier.

5. In C, the string constant is defined.

6. int * A = NULL;

Printf ("% P \ n", );

% P is output in address format

7. Char A [4] = {'A', 'B'}; // If an element in a [4] is not initialized, the elements in the array are garbled. As long as there is one // The initial state, all other uninitialized values are 0.

Printf ("% P \ n", );

Printf ("% P \ n", & A); where a refers to the address of the first element of array A, & A is the address of array, the two values are equal, but they have different meanings.

For example: printf ("% P \ n", A + 1 );

Printf ("% P \ n", & A + 1); the output address is removed four bytes because a contains four elements.

8,

# Define pchar *

Typedef char * pchar; // note the semicolon


Pchar px1, px2;

Pchar px1, px2;

Char CH = 'a ';

Px1 = & Ch;

Px2 = & Ch; // cannot convert from 'Char * 'to 'Char'

Px1 = & Ch;

Px2 = & Ch;

Px1 and px2 are both character pointers, because typedef gives another name for a type (here, char * is named pchar, that is, pchar is the pointer to the character, therefore, px1 and px2 are pointer types)


While define is just a macro replacement (replacing all the char * in the program with pchar), so it is equivalent

Char * px1, px2 (char * px1, px2); so only px1 is the character pointer, while px2 is the character type

9, 1) int const * pA;

2) int * const Pb;

(1) const is followed by * pA, which is a memory representation. Therefore, the content of the memory unit pointed to by PA is immutable.


10. Put the static modifier in the static zone and end with the program running, but not necessarily visible throughout the program

1) Static modifier,


2) static variable Modifier

File level: it is stored in the static zone. After modification, it is still in the static zone.

Block level: it is originally stored in the stack and stored in the static zone after being modified by the static state. The lifetime is at the program level.

Function parameters: cannot be modified statically.

11. Both GCC and CC are used to compile C language programs in Linux.

G ++ is used to compile C ++ programs.

2) Rm-F: name of the deleted file

12. Pre-processing (header file, macro definition, note: Replace the comment with a space) ---- compile --- Link

13 ,?? (------[

?? <------{

/A can beep

14. Volatile: the compiler is not allowed to perform type optimization.

15. While (1)

{

Break; // can jump out of the loop

}

While (1)

{

Continue; // unable to jump out

}


16. Writing specification: The switch statement must contain the default statement, even if the default statement does not work

17,

This article is from the "xingnallu" blog, please be sure to keep this source http://781588100.blog.51cto.com/9429625/1559199

C trivial knowledge points

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.