#include <iostream>
#include <stdio.h>
#include<process.h>
using namespace std;
bool mall(int size,int *p)
{
if (size< 0)
cout << "不能分配";
p = (int*)malloc(sizeof(int)*size);
if (p != 0)
cout << "申请成功 "<<"地址是:"<<p;
else
cout << "申请不成功";
}
void main()
{
mall(5);
system("pause");
}
#include <stdio.h>
#include<process.h>
using namespace std;
bool mall(int size,int *p)
{
if (size< 0)
cout << "不能分配";
p = (int*)malloc(sizeof(int)*size);
if (p != 0)
cout << "申请成功 "<<"地址是:"<<p;
else
cout << "申请不成功";
}
void main()
{
mall(5);
system("pause");
}