重新拾起c——符号 - webdancer's Blog

重新拾起c——符号

webdancer posted @ 2010年4月10日 01:56 in 编程语言 with tags c/c++ , 5870 阅读

 

以上为符号的列表。对符号我们就是知道他们经常用的意思!

注意:

1)/* :是注释号,编译器会自动寻找*/与之匹配。int  i = 8; int  * pi=&i;  int j=i/*pi; j的定义有问题。应为:j=i/(*pi);

2)对一个新手来说,注释可能很重要!要写好。

3)\:持续符和转义符。

转义字符转义字符的意义
\n 回车换行
\t 横向跳到下一制表位置
\v 竖向跳格
\b 退格
\r 回车
\f 走纸换页
\\ 反斜扛符"\"
\' 单引号符
\a 鸣铃
\ddd 1~3 位八进制数所代表的字符
\xhh 1~2 位十六进制数所代表的字符

4)逻辑运算符:

&& ,||  :自动判断,如果前面可以判定真假,后面就不理会了。

5)位运算符:

& 按位与
| 按位或
^ 按位异或
~ 取反
<< 左移
>> 右移

位运算符对底层编程很重要。

6)++,--。

有些人不建议使用++,--。因为很多时候,非常容易造成错误!其实,就是优先级问题。对优先级加括号应该是一个好方法!

8)优先级:

尽管我们可以通过加括号來控制,但是阅读他人的代码,还是很有用!

  Operator(s) Description Associativity
17
:: global scope (unary)
right-to-left
17
:: class scope (binary)
left-to-right
16
-> . member selectors
left-to-right
16
[ ] array index
left-to-right
16
( ) function call
left-to-right
16
( ) type construction
left-to-right
16
sizeof size in bytes
left-to-right
15
++ -- increment, decrement
right-to-left
15
~ bitwise NOT
right-to-left
15
! logical NOT
right-to-left
15
+ - unary plus, minus
right-to-left
15
* & dereference, address-of
right-to-left
15
( ) cast
right-to-left
15
new delete free store management
right-to-left
14
->* .* member pointer selectors
left-to-right
13
* / % multiplicative operators
left-to-right
12
+ - arithmetic operators
left-to-right
11
<< >> bitwise shift
left-to-right
10
< <= > >= relational operators
left-to-right
9
== != equality, inequality
left-to-right
8
& bitwise AND
left-to-right
7
^ bitwise exclusive OR
left-to-right
6
| bitwise inclusive OR
left-to-right
5
&& logical AND
left-to-right
4
|| logical OR
left-to-right
3
? : arithmetic if
left-to-right
2

= *= /* %= += -=
<<= >>= &= |= ^=

assignment operators
right-to-left
1
, comma operator
left-to-right

当然,得经常调试代码!

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee