1

I write this program in a code block, but I am having an error stray 302 in int86(0x33, ®s, ®s);. My program is:

#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();
}

I find some blog where it writes about the dos.h file. Is it work full to see the dos.h file? Is there a difference between the new dos.h file and the old dos.h file?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 8
    This is antique non-portable code. I doubt will work on any post-2000 OS. – vsoftco Dec 03 '15 at 05:18
  • Which operating system are you using? Did you consider using the [ncurses](https://www.gnu.org/software/ncurses/) library? Notice that `dos.h` & `conio.h` is *not* a standard header. If you want some GUI interface use some toolkit like [Qt](http://qt.io) or [libsdl](https://www.libsdl.org/)... – Basile Starynkevitch Dec 03 '15 at 05:40
  • i am using windows server 2003 os – user2111291 Dec 03 '15 at 06:11
  • 1
    The _int86_ calls you're making are for **16-bit MS-DOS** and will not work on a Windows program. – 1201ProgramAlarm Dec 03 '15 at 06:31
  • 1
    @vsoftco DOS programs should work fine in any Windows version older than Vista. Support was not dropped before that. – VLL Dec 03 '15 at 06:40
  • in my above program i change the sim-bole ® with & now my compiler compile full program but now it give me error in graphics.h file the error is "redefinition of int right ". in this line of graphics.h file "int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,". now how i can solve the problem of "redefinition of int right"?????? – user2111291 Dec 03 '15 at 06:50
  • 2
    Borland Graphics Interface. Now that's a name I haven't heard in a long time... – void_ptr Dec 03 '15 at 06:51
  • 1
    What is `®s` supposed to be?? – M.M Dec 03 '15 at 08:42
  • What is meant by *"Is it work full to see the dos.h file?"* (seems incomprehensible)? – Peter Mortensen May 01 '23 at 13:29
  • The error is under-reported here. From the code as posted, the offending character is Unicode code point U+00AB ([REGISTERED SIGN](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=128)) (UTF-8 sequence 0xC2 0xAE (hexadecimal), 302 256 (octal)). And the compiler error is expected to be the doublet "`error: stray \302. error: stray \256.`" (for each one of those characters (a single character giving rise to two compiler errors (or at least as reported))). – Peter Mortensen May 01 '23 at 13:44
  • cont' - REGISTERED SIGN can be searched for (and replaced) by the regular expression `\x{00AE}` in any modern text editor or IDE (note: The notation is different in Visual Studio Code (and probably others): `\u00AE` (instead of `\x{00AE}`)). There are 10 instances of this character in the code as posted. There aren't any other strange characters of the common ones often encountered, e.g. NO-BREAK SPACE, ZERO WIDTH SPACE, ZERO WIDTH NON-JOINER, ZERO WIDTH NO-BREAK SPACE, EN DASH, EM DASH, LEFT DOUBLE QUOTATION MARK, RIGHT DOUBLE QUOTATION MARK, MINUS SIGN, etc. – Peter Mortensen May 01 '23 at 13:55
  • This is a ***very*** common error when copying code from web pages, [PDF](https://en.wikipedia.org/wiki/Portable_Document_Format) documents, through chat (e.g. [Skype Chat](https://en.wikipedia.org/wiki/Features_of_Skype#Skype_chat) or [Facebook Messenger](https://en.wikipedia.org/wiki/Facebook_Messenger)), etc. The canonical question is *[Compilation error: stray ‘\302’ in program, etc.](https://stackoverflow.com/questions/19198332)*. – Peter Mortensen May 01 '23 at 13:55
  • Though this may be one of the few instances where it is actually caused by the editor (see the answer), `&reg` being autocompleted (by the user?) to the [HTML character entity reference `®`](https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML) and then automatically converted into U+00AB ([REGISTERED SIGN](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=128)), [®](https://en.wikipedia.org/wiki/Registered_trademark_symbol). – Peter Mortensen May 01 '23 at 13:58
  • Note: 302 and 342 (octal. 0xC2 and 0xE2, respectively) are signatures for (the start of) UTF-8 sequences (not the only ones, but the most common). They could also accidentally be on some [code page](https://en.wikipedia.org/wiki/Code_page#DOS_code_pages), but that is unlikely. – Peter Mortensen May 01 '23 at 14:20

1 Answers1

4

I think you have a problem with your editor. It has changed &reg to the registered trademark sign ®, which is an invalid symbol in a C program.

Compile error "stray \302" means you have an invalid character in your program. In your case, the character is ®. You should change line int86(0x33,®s,®s) to int86(0x33, &regs, &regs);.

For function call int86, the second parameter is input register and third parameter is output register. I think you are trying to use regs for both. Note that it would be better to use two separate variables for input and output. Documentation for int86().

VLL
  • 9,634
  • 1
  • 29
  • 54
  • in my above program i change the sim-bole ® with & now my compiler compile full program but now it give me error in graphics.h file the error is "redefinition of int right ". in this line of graphics.h file "int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,". now how i can solve the problem of "redefinition of int right"?????? – user2111291 Dec 03 '15 at 06:51
  • 1
    @user2111291 You are defining a variable `int right` two times. You can only define it once. You must rename one of those variables. I think your code should be `int left=0; int top=0; int right=INT_MAX; int bottom=INT_MAX;` – VLL Dec 03 '15 at 06:53