C语言常用语法提要(一)

  1. Identifier

Identifiers can consist of letters, numbers, and underscores. Identifiers must begin with a letter or underscore, and case letters are considered to be two different characters. Different systems have different regulations on the number of characters of identifiers, generally allowing 7 characters.

  1. Constant
    You can use:

    (1) Integer constant
    Decimal constant.
    Octal constant (a sequence of numbers starting with 0).
    Hexadecimal constant (a sequence of numbers starting with 0x).
    Long integer constant (followed by a number with the character L or L).

    (2) Character
    Constant is a character extended by a single apostrophe. Escape characters can be used.

    (3) Real constant (floating point constant)
    Decimal form.
    Eexponential form.

    (4) A sequence of characters enclosed by double apostrophes.

  2. Expression

(1) Arithmetic expression
Integer expression: the amount of operation involved in the operation is an integer, and the result is an integer.
Real type expression: the operation amount involved in the operation is real type, which is converted to double type in the operation process, and the result is double type.

(2) A logical expression is an integer connected by a logical operator, resulting in an integer (0 or 1). Logical expression can be regarded as a special form of integer expression.

(3) An integer connected by a bitwise operator, resulting in an integer.
Bit expressions can also be considered as a special form of integer expressions.

(4) A cast expression casts the type of an expression with the (type) operator, such as (float) (a).

(5) Comma expression (sequential expression)
in the form of:
expression 1, expression 2,… , expression n
in order to find expression 1, expression 2,… , the value of expression n, and the result is the value of expression n.

(6) The assignment expression assigns the value of the expression on the right side of the assignment number to the variable on the left side of the assignment number. The value of the assignment expression is the value of the variable assigned after the assignment.

(7) The form of conditional expression is: logical expression? Expression 1: expression 2.
If the value of logical expression is non-zero, the value of conditional expression is equal to the value of expression 1; if the value of logical expression is zero, the value of conditional expression is equal to the value of expression 2.

(8) pointer expression Operate on data of pointer type, for example, P-1, P1-P2, etc. (where P1, P2, P3 have been defined as pointer variables to array, P1 and P2 point to operations in the same array), and the result is pointer type.

The above expressions can contain related operators, or they can be initial equivalents without any operators (for example, constants are the simplest form of arithmetic expressions).*

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值