标题:
函数指针,为什么这么写是错误的
[打印本页]
作者:
misssir
时间:
2008-4-25 09:50
标题:
函数指针,为什么这么写是错误的
void hello()
{
printf("hello every one");
}
#define BYTE unsigned char
#define WORD unsigned int
#define DWORD unsigned long
DWORD ptr_hello;
void main()
{
WORD* ptr = (WORD *)ptr_hello;
ptr[1] = FP_SEG(&hello);
ptr[0] = FP_OFF(&hello);
__asm
{
call ptr_hello
}
while(!kbhit());
}
我想做一下实验,结果是编译通过,不能执行,说CPU遇到无效的命令,请教为什么这样不行呢
作者:
misssir
时间:
2008-4-25 10:04
标题:
惭愧,我写错了
WORD* ptr = (WORD *)ptr_hello;
应该是 WORD* ptr = (WORD *)(&ptr_hello);
欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/)
Powered by Discuz! 2.5