mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-03 02:24:11 +08:00
support bazel complie this project and format code.
This commit is contained in:
14
practical_exercises/key_exercises/array.cpp
Normal file
14
practical_exercises/key_exercises/array.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
/* 数组.cpp */
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user