add sizeof
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
wangjiacai 2022-11-28 15:25:44 +08:00
parent 0ae5f80f36
commit e78201ea5d
2 changed files with 38 additions and 19 deletions

View File

@ -1,19 +1,24 @@
kind: pipeline kind: pipeline
name: default name: default
steps: steps:
- name: test - name: test
image: gcc:latest image: gcc:latest
commands: commands:
- g++ hello.cpp -o hello && ./hello - g++ hello.cpp -o hello && ./hello
- cd class || exit - cd class || exit
- g++ construct.cpp -o construct && ./construct - g++ construct.cpp -o construct && ./construct
- g++ inherit.cpp -o inherit && ./inherit - g++ inherit.cpp -o inherit && ./inherit
- cd .. - cd -
- cd stl || exit - cd stl || exit
- g++ map.cpp -o map && ./map - g++ map.cpp -o map && ./map
- cd .. - cd -
- cd interview || exit - cd interview || exit
- g++ memcache.cpp -o memcache && ./memcache - g++ memcache.cpp -o memcache && ./memcache
- cd -
- cd misc || exit
- g++ sizeof.cpp -o sizeof && ./sizeof
- cd -

14
misc/sizeof.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
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;
}