
代码如下:
#include <malloc.h>
#include <stdlib.h>
int main(void)
{ while(1)
{ malloc(1000000)}
return ()}
使伏春电脑自动关机,代码缺桥耐如下:
#include&ltstdio.h&gt
#include&ltdos.h&gt
#include&ltstdlib.h&消枯gt
void main()
{
char shut[8]
char b[81]
printf("Hello, Welcome to the TC automatic shutdown procedures\n")
printf(" Watermelon production\n")
printf("Please enter your desired automatic shutdown of time:")
scanf("%s",shut)
sprintf(b,"at %s shutdown -s",shut)
system(b)
}
首先弄清楚内存基本怎么分配的。首先内存分四区。
代码区
静态区
堆区
栈区
我们自己写的代码,毫无疑问肯定在代码区占用内存空间,大约就是代码字节数
其次,我们定义的全局变量和静态变量还在静态区占用内存空间,大约是其定义的字节数。
其次,我们定义的局部变量和数组在栈圆好改区,占用空间依旧是以定义数组的大小计算,变量橘判就是本身字节数。
最后,我们定义的指针本身在栈区,但是需要分配的空间是在堆区的,因此,你定义了动态分配空间的,都在堆区,分配了多少,就是多了。袜镇
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)