int *A;
int size;
A = new int[size];
size = 2;
A[0] = 100;
A[1] = 200;
CString Msg;
Msg.Format("%d",A[0]);
MessageBox(Msg);
delete[] A;
一执行就说内存不足,为什么?
int size;
A = new int[size];
size = 2;
A[0] = 100;
A[1] = 200;
CString Msg;
Msg.Format("%d",A[0]);
MessageBox(Msg);
delete[] A;
一执行就说内存不足,为什么?
解决方案 »
- directx 9的连接问题?
- va_list是个什么类型啊? 里面具体是什么内容? 请各位大虾帮忙!
- 关于CBitmap的LoadBitmap的问题
- 坐标问题
- 感谢sinall(走或留,这是个问题)帮忙,进来取分!
- 两个按钮(button)触发相同的函数体,在函数体里如何分辨是那一个按钮触发的?
- google问题,欢迎各位大侠讨论。听说是sina封的google...
- 数组、类、变量、Cstatic
- 如何修改状态条的显示:
- vc++ MFC listcontrol 控件的GetItemText问题
- NetMessageBufferSend() API 发送信息会乱码吗?
- 只知道一个程序的路径,如何得到它运行后的句柄?
int *A;
int size = 100;
A = new int[size];
根本没有分到内存
int size;
size = 2; //这两行互换就行了
A = new int[size]; //原来在上一行的上面
A[0] = 100;
A[1] = 200;
CString Msg;
Msg.Format("%d",A[0]);
MessageBox(Msg);
delete[] A;
A = new int[size];
size局部变量,没有初始化,是一个内存中的随机值
可能非常大,当然就说你内存不足了
要是全局变量,或是静态变量定义时就初始化了为0
但是局部变量,没有初始化
最好用 如:const int Temp=100;define Temp 100;(我的观点)
初始值是DOS 是 2^16
WIN 是2^32
当然不够拉
huang_yi_cn(蓝色的云):right!