c++ - 函数 int86 编译错误 : "Stray 302",

标签 c++ c bgi

我在代码块中编写此程序,但在 int86(0x33,®s,®s); 中出现错误 302。我的程序是

#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<graphics.h>

void theend();

static int mask[]={/*SCREEN MASK*/
           0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
           0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
                   0x0000,0x0000,
           /*CURSOR MASK*/
           0x0000,0x0000,0x381c,0x7c3e,0x7c3e,0x7c3e,0x7c3e,
           0x3bdc,0x07e0,0x0ff0,0x0ff0,0x0ff0,0x0ff0,0x07e0,
           0x03c0,0x0000};


void main()
{int gdriver=DETECT,gmode,buttons;
 union REGS regs;
 struct SREGS sregs;
 initgraph(&gdriver,&gmode,"");
 regs.x.ax=0;                        /*INITIALIZE MOUSE*/
 int86(0x33,®s,®s);
 setcolor(LIGHTCYAN);
 if(regs.x.ax==0)
   {outtextxy(0,0,"NO MOUSE AVAILABLE");
    getch();
    theend();
   }
 regs.x.ax=9;                       /*CHANGE CURSOR SHAPE*/
 regs.x.bx=5;
 regs.x.cx=0;
 regs.x.dx=(int)mask;
 segread(&sregs);
 sregs.es=sregs.ds;
 int86x(0x33,®s,®s,&sregs);
 regs.x.ax=1;                       /*SHOW MOUSE POINTER*/
 int86(0x33,®s,®s);
 do
   {regs.x.ax=3;
    int86(0x33,®s,®s);
    buttons=regs.x.bx & 3;
   }while(buttons!=3);
 regs.x.ax=2;                       /*HIDE MOUSE POINTER*/
 int86(0x33,®s,®s);
 theend();
}

void theend()
{closegraph();}

我找到一些博客,其中写了关于 dos.h 文件的内容。查看 dos.h 文件是否正常工作?新的dos.h 文件和旧的dos.h 文件有区别吗?

最佳答案

我认为您的编辑器有问题。它已将®更改为注册商标符号®,这是C程序中的无效符号。

编译错误“stray\302”意味着您的程序中有无效字符。在您的例子中,字符是 ®。您应该将 int86(0x33,®s,®s) 行更改为 int86(0x33, ®s, ®s);

函数调用int86,第二个参数为输入寄存器,第三个参数为输出寄存器。我认为您正在尝试对两者都使用 regs 。请注意,最好为输入和输出使用两个单独的变量。 Documentation for int86().

关于c++ - 函数 int86 编译错误 : "Stray 302",,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34058372/

相关文章:

c++ - 如何沿着 body 改变分配给刚体的点​​?

c - 关于 C 中类型转换的警告

ios - 在 XNU 内核上查找某个函数的指针的最佳方法是什么?

与二维数组混淆

未找到 C++ graphics.h -lbgi

c++ - 如何修复 Turbo C++ 错误 "Cannot open include file: graphics.h: no such files or director"

c++ - Codeblocks 中的图形程序

c++ - sscanf()的问题不会读取char数组中的每个0

c++ - 如何在 C++ 中判断应用程序在何处运行

c++ - OpenCV 3.0.0 MSER 二进制掩码