C Language Knowledge (2)

Source: Internet
Author: User

while (n) First, n is treated here as a condition
Second, when N is true, it enters the while loop body (A), otherwise the jump-out loop continues with the following section (B).
N is 0 o'clock condition is false n not 0 condition is true

while (j) {
if (j%10 = = 2) How to split an integer
counter++;
J/= 10;}

If the first character of an integer constant is the number 0, the constant is treated as an octal number. So the meaning of 10 and 010 is very different.

Sometimes it is important to note that the decimal number may inadvertently be written as an octal number in context in order to justify formatting.

A character enclosed in single quotation marks actually represents an integer

But the judging condition can be if (d== ' R ')

The function of the return statement is to end the execution of the function and return the return value as a result. The return value is either a constant, a variable, or a complex expression. If the return value type is void, you can write the return directly;.

6.4-bit arithmetic

Used to manipulate one (bit) or several bits in a variable of integer type (int, char, long, and so on).

Six bit Operators:& | ^ ~ << >>

&: Usually used to take some position in a variable to 0 while preserving other bits, or to get one of the variables.

|: Typically used to place some position in a variable at 1 while preserving other bits unchanged.

^: it is usually used to reverse some bits in a variable and leave the other bits intact. Features: If a^b = c, then c^b = A,c^a = B, can be used for simple encryption and decryption. The value of two variables can also be exchanged without a temporary variable.

eg.  int a = 5, B = 7;  A = A^b;  b = b^a;  A = A^b; Can realize the exchange of A/b value.

~: Monocular operator.

<<:a << B, the value that is obtained by moving a each of the binaries to the left B-bit. When moving left, the high drop and the value of the low complement 0,a are not changed by operation. In fact, moving the left 1 bits is the equivalent of multiplying by 2, and the left shift is much faster than the multiplication operation.

>>:a >> B, the value of the all-in-one binary is shifted by the B-bit. When you move right, the rightmost bit is discarded, and the value of a does not change. Shift right one is equivalent to dividing by 2, and the result is rounded to the small.

For signed numbers (char, int, long, and so on), the symbol bit (that is, the highest bit) moves together when you move right. The original sign bit is 1, the high level is added 1; it's 0 o'clock.

2. String constants occupy memory of the number of bytes equal to the number of characters in the string +1, the extra is the end of the character ' \ s ', the length of the string does not include ' s '.

3. "" is also a valid string constant, called an empty string, that will still occupy a byte of storage space '.

. String functions determine the end of a string according to ' ?? '

C language Knowledge (2)

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.