#include<iostream.h>
int main(void)
{
const count=3;
const *p=&count;
for(int i=0;i<=*p;i++)
{
cout<<"hello,world"<<endl;
}
return 0;
}
int main(void)
{
const count=3;
const *p=&count;
for(int i=0;i<=*p;i++)
{
cout<<"hello,world"<<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;
}
#include<iostream.h>
int main(void)
{
int x=3;
int &y=x;
cout<<"x="<<x<<",y="<<y<<endl;
y=4;
cout<<"x="<<x<<",y="<<y<<endl;
}
int main(void)
{
int x=3;
int &y=x;
cout<<"x="<<x<<",y="<<y<<endl;
y=4;
cout<<"x="<<x<<",y="<<y<<endl;
}
c 语言{
申请 void *malloc(size_t size);
释放 void free(void *memblock);
}
申请 void *malloc(size_t size);
释放 void free(void *memblock);
}
2017-08-03
#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;
}
int *p = new int(1);
delete p;
p = NULL;
int *p = new int[1];
delete []p;
p = NULL;
delete p;
p = NULL;
int *p = new int[1];
delete []p;
p = NULL;
2017-08-01
#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y = x;
//打印x和y的值
cout<<x<<endl;
cout<<y<<endl;
//修改y的值
y = 1;
//再次打印x和y的值
cout<<x<<endl;
cout<<y<<endl;
return 0;
}
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y = x;
//打印x和y的值
cout<<x<<endl;
cout<<y<<endl;
//修改y的值
y = 1;
//再次打印x和y的值
cout<<x<<endl;
cout<<y<<endl;
return 0;
}