具有常量的Typedef指针

时间:2018-09-12 21:05:14

标签: c

我在下面的代码c中使用了typedef

typedef int* IPTR;
const IPTR  p;
*p = 10;
//p = 0x1F00;

但是有一些问题

typedef int* IPTR; // this means -> IPTR = int* 
const IPTR p;      // this means -> const int* p;
                   // in this content  *p must be constant but it is not
*p = 10;           // is valid however p = 0x1F00; is unvalid

为什么倒过来

const IPTR p;看起来像-> int* const p;,而不是-> const int* p;

0 个答案:

没有答案