C动态内存分配 [英] C dynamic memory allocation

查看:74
本文介绍了C动态内存分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void main()
{
	long int *ptr;
	clrscr();
	ptr=(long int*)malloc();
	*ptr=123456789;
	printf("%ld",*ptr);
	getch();
}

here I have not defined the size of malloc than also
it printing what is the reason

What I have tried:

output on the console is 123456789

推荐答案

引用:

这里我还没有定义malloc的大小比

它打印的原因是什么

here I have not defined the size of malloc than also
it printing what is the reason



检查动态内存分配是你的职责,正确使用malloc()是你的责任。

C会接受任何事情直到它崩溃。



建议:阅读malloc()文档。


Checking the dynamic memory allocation is your duty, making proper usage of malloc() is your responsability.
C will accept anything until it crash.

Advice: read malloc() documentation.


这篇关于C动态内存分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆