a little advice

A

ash

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
 
R

Richard Heathfield

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.
 
M

Mark McIntyre

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top