-
-
未解决
[求助]关于Q版缓冲区溢出这本书在堆溢出章节的代码问题
-
发表于:
2018-11-13 10:48
2017
-
未解决 [求助]关于Q版缓冲区溢出这本书在堆溢出章节的代码问题
一下为完整代码
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
char mybuf[]="ww0830";
int main(int argc,char * argv[])
{
HANDLE hHeap;
char *buf1,*buf2;
hHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0x10000,0xfffff);
printf("mybuf addr = %p\n",mybuf);
buf1=HeapAlloc(hHeap,0,200);
strcpy(buf1,mybuf);
printf("buf1=%s\n",buf1);
buf2=HeapAlloc(hHeap,0,16);
HeapFree(hHeap,0,buf1);
HeapFree(hHeap,0,buf2);
return 0;
}
错误提示是
error C2440: '=' : cannot convert from 'void *' to 'char *'
错误语句是
buf1=HeapAlloc(hHeap,0,200);
请问这里怎么改?
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!