From e78201ea5d543d00b57cbf56a5b95bbfd401f479 Mon Sep 17 00:00:00 2001 From: wangjiacai Date: Mon, 28 Nov 2022 15:25:44 +0800 Subject: [PATCH] add sizeof --- .drone.yml | 43 ++++++++++++++++++++++++------------------- misc/sizeof.cpp | 14 ++++++++++++++ 2 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 misc/sizeof.cpp diff --git a/.drone.yml b/.drone.yml index 60d44e2..b3b3d40 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,19 +1,24 @@ -kind: pipeline -name: default -steps: - - name: test - image: gcc:latest - commands: - - g++ hello.cpp -o hello && ./hello - - - cd class || exit - - g++ construct.cpp -o construct && ./construct - - g++ inherit.cpp -o inherit && ./inherit - - cd .. - - - cd stl || exit - - g++ map.cpp -o map && ./map - - cd .. - - - cd interview || exit - - g++ memcache.cpp -o memcache && ./memcache \ No newline at end of file +kind: pipeline +name: default +steps: + - name: test + image: gcc:latest + commands: + - g++ hello.cpp -o hello && ./hello + + - cd class || exit + - g++ construct.cpp -o construct && ./construct + - g++ inherit.cpp -o inherit && ./inherit + - cd - + + - cd stl || exit + - g++ map.cpp -o map && ./map + - cd - + + - cd interview || exit + - g++ memcache.cpp -o memcache && ./memcache + - cd - + + - cd misc || exit + - g++ sizeof.cpp -o sizeof && ./sizeof + - cd - \ No newline at end of file diff --git a/misc/sizeof.cpp b/misc/sizeof.cpp new file mode 100644 index 0000000..8fafd39 --- /dev/null +++ b/misc/sizeof.cpp @@ -0,0 +1,14 @@ +#include + +using namespace std; + +char strs[2][1024]; + +int main() +{ + cout << sizeof(strs) << endl; + cout << sizeof(strs[0]) << endl; + cout << sizeof(strs[0][0]) << endl; + for (size_t i = 0; i < sizeof(strs) / sizeof(strs[0]); i++) + cout << sizeof(strs[i]) << endl; +} \ No newline at end of file