来嘛!来嘛!
#include <iostream>
#include <assert.h>
#include <stdlib.h>
using namespace std;
int main()
{
int i=0;
int *p=(int)malloc((int)sizeof(p)*1000);
assert(p!=0);
srand(time(NULL));
for(i=0;i<=999;i++)
{
*(p++)=rand();
}
for(i=0;i<=999;i++)
{
cout<<*(p++);
}
free(p);
system("pause");
return 0;
}
------ 已启动生成: 项目: wanghao, 配置: Debug Win32 ------
正在编译...
cc.cpp
d:\cc\wanghao\wanghao\cc.cpp(8) : warning C4311: “类型转换”: 从“void *”到“int”的指针截断
d:\cc\wanghao\wanghao\cc.cpp(8) : error C2440: “初始化”: 无法从“int”转换为“int *”
从整型转换为指针类型要求 reinterpret_cast、C 样式转换或函数样式转换
d:\cc\wanghao\wanghao\cc.cpp(10) : error C3861: “time”: 找不到标识符
生成日志保存在“file://d:\cc\wanghao\wanghao\Debug\BuildLog.htm”
wanghao - 2 个错误,1 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========