#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 <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;
}javascript:;
#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;
}javascript:;
已通过
#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;
//释放内存
delet []str;
str=NULL;
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;
//释放内存
delet []str;
str=NULL;
return 0;
}
int getMax(int *arr,int count)
{
int maxNum=arr[0];
for(int i = 1; i < count; i++)
{
if(arr[i]>maxNum)
{
maxNum=arr[i];
}
}
return maxNum;
}
int main(void)
{
int numArr[3] = {3, 8, 6};
cout << getMax(5, 6) << endl;
cout << getMax(numArr,3)<< endl;
return 0;
{
int maxNum=arr[0];
for(int i = 1; i < count; i++)
{
if(arr[i]>maxNum)
{
maxNum=arr[i];
}
}
return maxNum;
}
int main(void)
{
int numArr[3] = {3, 8, 6};
cout << getMax(5, 6) << endl;
cout << getMax(numArr,3)<< endl;
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 < count; 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 < count; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}