帮忙看一下这四句话

来源:百度知道 编辑:UC知道 时间:2024/05/27 10:47:07
const int buffer = 256; const double *point;
int const buffer = 256; double *const point;

都是代表什么意思(其中一句是错的)

楼上“做他”答案一半错误。

-----------------------------------------

#include <stdlib.h>

void main()
{
const int buffer = 256; // 正确,定义常量buffer并初始化为256
const double *point; // 正确,定义双精度常量指针point,
*point = 1.0; // 错误,point指向的内容不可修改
point = NULL; // 正确,point本身可以被修改

int const bufferX = 256; // 正确,等同于const int bufferX
double *const pointX; // 错误,指针pointX本身不可被修改,必须初始化
double pi_val = 3.14;
double *const pointY = &pi_val; // 正确。初始化pointY的地址为pi_val的地址。
}

int const buffer = 256; double *const point;
//错的

const int buffer = 256;
//定义一个整型常量
const double *point;
//定义一个双精度常量指针