10-0-1.cpp
来自「Accelerated C++ 课后练习题 本人自己完成、可供参考」· C++ 代码 · 共 25 行
CPP
25 行
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
using std::copy;
char* duplicate_chars(const char* p)
{
//allocate enouth space; remember to add one for the null
size_t length=strlen(p)+1;
char *result=new char[length];
//copy into our newly allocated space and return pointer to first element
copy(p,p+length,result);
return result;
}
int main()
{
int* p=new int(42);
cout<<*p++<<" "<<++*p<<endl;
//43 //43
char str[]="cheng ning is a good student";
cout<<duplicate_chars(str)<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?