NDK and C language basic syntax (ii)

Source: Internet
Author: User

First, the String class: (Belongs to the class type)-string (only in C + +)

You must learn to introduce the string type before use:

Introduction of String header file (System header File): #include <string> PS: header file is not string.h

1. Definition string: String a= "abc"; String b= "Abd";

2. String comparison: From left to right from the first character, compared to the size of the ASCII code

From the beginning look: A==a,b==b,c>d so a>b;

3. String array: The element string in the string array does not have an end bit such as '/';

Second, constant and variable

1. What is a constant:

Value cannot change the amount of 1 1.2 fixed value

Types of constants:

(1) Numeric constants (integers, floating-point numbers);

(2) Character-type constants (character constants, escaped character constants, string constants)

(3) Symbolic constant (#define constant value of the constant name of the symbol)

2. Variables

(1) Variables

The amount of value that can be changed during program run becomes variable;

Naming rules for variables: C + + Specifies that identifiers can only be composed of letters, numbers, underscores, and can only be case-sensitive by letter and underscore

Keywords and reserved words cannot be used;

(2) Constant variable

Variable with const keyword, program run time value cannot be changed, call constant variable

PS: The constant variable must be initialized at the time of definition, and thereafter his value cannot be changed;

Third, operator

1. Arithmetic operators:

+-*/% + +--

Subtraction dividing the remainder from adding self-subtraction

2. Relational operators:

> < = >= <=! =

Greater than or equal to or less than equals not equal to

The return value is bool (the return value in the C language is 0 and 1)

3. Logical operators:

&& | | !

Logical AND logical or logical non-

The two values before and after the logical operators are bool (the C language must be 0 and not 0 values);

&&: All true is true, as long as another one is false;

|| : As long as one is true;

! : Contrary to current;

4, Bitwise operators:

<< >> & | ^           ~

Bitwise LEFT SHIFT bitwise RIGHT SHIFT bitwise VS. bitwise OR bitwise XOR or bitwise REVERSE

Original code anti-code complement

5. Assignment operator =

(1) Meaning: Assigns the value to the right of the assignment operator (including the result of the last operation of the expression) to the variable to the left of the assignment operator;

A=1;

(2) Right binding of assignment operation

NDK and C language basic syntax (ii)

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.