指出下列程序片段中的错误标号,写出正确语句或解释错在何

指出下列程序片段中的错误标号,写出正确语句或解释错在何处。

1)

①int index=675;
②const int *ptr=&index;
③int *const ntptr=&index;
④*ptr=555;
⑤*ntptr=666;
⑥int another=8;
⑦ptr=&another;
⑧ntptr=&another;

2)

①int arrp;
②arrp=new int[15];
③delete arrp;
答案
第1空:④*ptr=555;ptr是指向整数常量的指针 / ⑧ntptr=&another; ntptr是常量指针,不能指向别的的变量
第2空:①intarrp;应改为:int *arrp; / ③delete arrp;应改为:delete [ ]arrp;

题目信息

题号:7586
题型:填空题
难度:普通