今天的筆記沒有乙個很好的標題,也很短。主要是針對&與操作符
a postfix expression followed by an expression in square brackets is a subscripted
designation of an element of an array object. the definition of the subscript operator
is that e1[e2] is identical to (*((e1)+(e2))). because of the conversion rules that
initial element of an array object) and e2 is an integer, e1[e2] designates the e2-th
element of e1 (counting from zero).
也就是說對於陣列array[10],實際上其等同於*((array)+(10)),也就等於10[array]。
也就說在*&null完全是合法的。
請看測試程式:
#include
#include
int main();
printf(
"p is %p and value is %d\n",&
*p, 2[
array])
;return 0;}
輸出:
p is (nil) and value is 3
C99標準轉義符大全
轉義字元是c語言中表示字元的一種特殊形式。通常使用轉義字元表示ascii碼字符集中不可列印的控制字元和特定功能的字元,如用於表示字元常量的單撇號 用於表示字串常量的雙撇號 和反斜槓 等。轉義字元用反斜槓 後面跟乙個字元或乙個八進位制或十六進製制數表示。轉義字元 意義 ascii碼值 十進位制 a 響...
C99標準學習筆記 4 sizeof運算子
本來認為對sizeof已經有了比較清晰的認識,沒想到一讀標準,發現自己還是理解錯了。因為我使用sizeof都是用於靜態的sizeof,也就是說sizeof的值在編譯階段就是可以確定的。當時將sizeof理解為乙個巨集了,用於計算型別或者變數所占用的位元組數。讀過c99標準,才發現sizeof既不是乙...
c 操作符過載 學習筆記
1.過載的限制 1 過載後的操作符必須至少有乙個運算元是使用者自定義的型別,這可以防止使用者把標準操作符給過載。比如 t operator double a,double b error 2 不能違反原來操作符的句法規則。3 不能定義新的操作符,否則那就不叫過載了。4 不能過載下面的操作符 size...