int x = 10; int y = 20; int* const ptr = &x; // ptr是常量指针,指向int类型 // ptr = &y; // 错误!不能修改ptr本身(指针不可变) *ptr = 30; // 正确!可以修改ptr指向的内容(x变为30)