#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str = new char[100]
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(char[100], "Hello imooc");
cout<<str<<endl;
//释放内存
delete []string;
str=NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str = new char[100]
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(char[100], "Hello imooc");
cout<<str<<endl;
//释放内存
delete []string;
str=NULL;
return 0;
}
//const
#include <iostream>
using namespace std;
int main(void)
{
//定义常量count
const int count = 3;
const int *p = &count;
//打印count次字符串Hello C++
for(int i = 0; i < *p; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//定义常量count
const int count = 3;
const int *p = &count;
//打印count次字符串Hello C++
for(int i = 0; i < *p; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}