這個答案錯了吧
如果僅僅要指針可指向const定義的變量,只用`const int *p = &a;` 或 `int const *p = &a;` 就可以了吧。
如果要指針指向也不可修改,那么不應(yīng)該是 `const int *const p = &a;` 或者 `int const *const p = &a;`嗎?
答案的 `const int const *p = &a;` 是什么意思?
如果僅僅要指針可指向const定義的變量,只用`const int *p = &a;` 或 `int const *p = &a;` 就可以了吧。
如果要指針指向也不可修改,那么不應(yīng)該是 `const int *const p = &a;` 或者 `int const *const p = &a;`嗎?
答案的 `const int const *p = &a;` 是什么意思?
2018-02-13
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
char*str =new char[100];
//在堆中申請100個char類型的內(nèi)存
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(str, "Hello imooc");
count<<str<<endl;
//打印字符串
delete []str;
//釋放內(nèi)存
str ==NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
char*str =new char[100];
//在堆中申請100個char類型的內(nèi)存
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(str, "Hello imooc");
count<<str<<endl;
//打印字符串
delete []str;
//釋放內(nèi)存
str ==NULL;
return 0;
}