NULL和const

// In C, NULL is limited to identifying a null pointer.
// 在C中,它是一个宏
#define NULL ((void *)0)

'\0' is defined to be a null character - that is a character with all bits set to zero.

const

// const表示read-only的变量,和完全意义上的常量还不太一样
The const qualifier really means "read-only".
const in C never means constant but it means ready-only.
<1> is an integer constant as of the C standard.<const int i> is still a variable!
an object so qualified is a run-time object which cannot (normally) be assigned to.
The value of a const-qualified object is therefore not a constant expression in the full sense of the term,
and cannot be used for array dimensions,case labels,and the like.

char * const env[]//array of const pointer to char
const char * env[]//array of pointer to const char
// 这两个是一样的,pointer to a const char
const char *p
char const *p
// const pointer to char(i.e you can't change the pointer).
char * const p

Clockwise/Spiral Rule

There is a technique known as the "Clockwise/Spiral Rule" which enables any C programmer to parse in their head any C declaration!
There are three simple steps to follow:
1.Starting with the unknown element, move in a spiral/clockwise direction;when ecountering the following elements replace them
with the corresponding english statements:
[X] or []//=> Array X size of... or Array undefined size of...
(type1, type2)//=> function passing type1 and type2 returning...
*//=> pointer(s) to...
2.Keep doing this in a spiral/clockwise direction until all tokens have been covered.
3.Always resolve anything in parenthesis first!

https://c-faq.com/decl/spiral.anderson.html
https://stackoverflow.com/questions/8091770/const-char-and-char-const-are-they-the-same
https://stackoverflow.com/questions/890535/what-is-the-difference-between-char-const-and-const-char
https://stackoverflow.com/questions/6580324/2-simple-variable-initialization-question
https://c-faq.com/decl/cdecl1.html
https://cdecl.org/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值