Update 动态数组.cpp

This commit is contained in:
Francis
2020-06-14 19:25:27 +08:00
committed by GitHub
parent 93f3d96f03
commit 1ca9bceb61

View File

@@ -1,5 +1,14 @@
#include<iostream>
char *sPtr; //<2F><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
s="<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
sPtr = new char[strlen(s)+1];
strncpy(sPtr,s;
#include<cstring>
int main() {
char *sPtr;
const char* s="hello";
sPtr = new char[strlen(s)+1];
strncpy(sPtr,s,strlen(s));
std::cout << sPtr << std::endl;
delete sPtr;
return 0;
}