【发布时间】:2013-08-13 14:16:04
【问题描述】:
我正在查看 C99 规范 (N1256.pdf),上面写着 (p.11506):
const int *ptr_to_constant;
int *const constant_ptr;
"ptr_to_constant指向的任何对象的内容都不能通过那个指针来修改,但是ptr_to_constant本身可以被改变为指向另一个对象。同理,constant_ptr指向的int的内容可以修改,但是constant_ptr本身应始终指向同一个位置。” (6.7.5.1 指针声明器)
现在,根据我之前阅读的内容,以下两个语句会产生相同的行为。
int *const constant_ptr; /* This form is mentioned in the standard */
int const *constant_ptr; /* This form is NOT mentioned in the standard */
我想知道第二种形式是正确的还是只是扩展名。
提前致谢, -S
【问题讨论】: