#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str =new char(100);
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(str, "Hello imooc");
//打印字符串
cout << str << endl;
//释放内存
delete []str;
str = NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str =new char(100);
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(str, "Hello imooc");
//打印字符串
cout << str << endl;
//释放内存
delete []str;
str = NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y = x;
//打印x和y的值
cout << x << endl;
//修改y的值
y = 4;
//再次打印x和y的值
cout << x << endl;
return 0;
}
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y = x;
//打印x和y的值
cout << x << endl;
//修改y的值
y = 4;
//再次打印x和y的值
cout << x << endl;
return 0;
}
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str = new char[100];
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//释放内存
delete []str;
str=NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str = new char[100];
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//释放内存
delete []str;
str=NULL;
return 0;
}