C++和C程序内存占用对比分析
C++和C程序内存占用对比分析
本例以简单程序为例,分析C++和C语言的内存占用情况。本运行环境为:
- Ubuntu 20.04 LTS
- G++/GCC version: 9.3.0
- libstdc++.so.6.0.28/libc-2.31.so
1,C代码文件为hello.c,C++代码文件为hello.cpp:
/* hello.c */
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("hello world
");
pause();
return 0x0;
}

![C++和C程序内存占用对比分析[编程语言教程]](https://www.zixueka.com/wp-content/uploads/2024/01/1706713445-1035d0027e771b8.jpg)
