a little advice

Discussion in 'C Programming' started by ash, Jan 15, 2006.

  1. ash

    ash Guest

    hi friends,

    i was trying to make a function, which returns the scan code of a key
    like up arrow,down arrow, right arrow and left arrow. here it is-

    #include<dos.h>

    int getkey()
    {
    union REGS i,o;

    while(!kbhit())
    ;
    i.h.ah=0;
    int86(22,&i,&o);
    return(o.h.ah);
    }
    and there was also rest of program but i didn`t mention here.

    but when i try to compile it in BORLAND C++ 5.02 AND MICROSOFT VISUAL
    C++ 6.0 ,it gives a lot of error i.e. union REGS not defined, i and o
    undefined, int86 should have prototype and so on.
    then i tried to compile same program in TURBO C 3.0 and it succeeded
    and my program is working fine. I want to know why this piece of code
    was giving error in borland 5.02 and VC++?
    is there anyway to correct it.
    thankx
    ash
     
    ash, Jan 15, 2006
    #1
    1. Advertising

  2. ash said:

    > but when i try to compile it in BORLAND C++ 5.02 AND MICROSOFT VISUAL
    > C++ 6.0 ,it gives a lot of error i.e. union REGS not defined, i and o
    > undefined, int86 should have prototype and so on.
    > then i tried to compile same program in TURBO C 3.0 and it succeeded
    > and my program is working fine. I want to know why this piece of code
    > was giving error in borland 5.02 and VC++?


    Because what you wrote is not actually standard C. I mean, the syntax is
    standard enough, but the stuff you were using (int86() calls, REGS unions,
    and all that) was a pile of extensions that were common to MS-DOS compilers
    back in the 1980s and early 1990s (hence "dos.h"), but which fell out of
    favour when Microsoft (R) Windows (TM) 95 (aka 4) was introduced.

    > is there anyway to correct it.


    If you need *that* code to work, use a very old MS-DOS compiler (I keep
    several around, just in case!). If you just need that functionality, yes,
    there are more "modern" ways to do it, but none of those ways can be
    followed in standard C - every implementation does it in its own way, it
    seems - which is a nuisance. Since, presumably, you are on a Windows
    platform, comp.os.ms-windows.programmer.win32 would be your next port of
    call.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, Jan 15, 2006
    #2
    1. Advertising

  3. On 14 Jan 2006 22:22:07 -0800, in comp.lang.c , "ash"
    <> wrote:

    >hi friends,
    >
    >i was trying to make a function, which returns the scan code of a key


    See the FAQ, section 19

    >but when i try to compile it in BORLAND C++ 5.02 AND MICROSOFT VISUAL
    >C++ 6.0 ,it gives a lot of error i.e. union REGS not defined, i and o
    >undefined, int86 should have prototype and so on.


    Different compilers have different abilities. Different OSes have
    different abilities. For further details, ask again in a Windows
    programming group as how you would do it under Unix, VMS, etc would be
    totally different, and all would be offtopic in CLC.

    Mark McIntyre
    --

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Mark McIntyre, Jan 15, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil
    Replies:
    0
    Views:
    390
  2. Adam Schroeder

    can someone give me a little advice.

    Adam Schroeder, Sep 11, 2003, in forum: C++
    Replies:
    2
    Views:
    335
    Govindan
    Sep 12, 2003
  3. John Salerno

    advice on this little script

    John Salerno, Mar 9, 2006, in forum: Python
    Replies:
    32
    Views:
    864
    R. Bernstein
    Apr 8, 2006
  4. ThaDoctor
    Replies:
    3
    Views:
    393
    Alan Woodland
    Sep 28, 2007
  5. Daniel
    Replies:
    1
    Views:
    220
    Bart van Ingen Schenau
    Jul 9, 2013
Loading...

Share This Page