far Pointers in C programming. Solve the code

The following codes works perfect in TurboC3.0. How to run this in VS2010.

Advance Thanks to all.


#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int far *p= (int far *) 0x417;
char c;
clrscr();
while(c!=27)
{
if(kbhit())
c=getche();
if(*p&64) //64 is the code of CAPSLOCK key.
{
gotoxy(3,1);
printf("Caps Lock Is ONN");
}
else
{
gotoxy(3,1);
printf("Caps Lock Is OFF");
}
}

getch();
}
> How to run this in VS2010.
Throw away TurboC3.0

Learn how to program the Win32 API by going to MSDN (https://msdn.microsoft.com/en-us/dn308572.aspx)


There is nothing like a far pointer in modern C[++].

Instead of the pointer use the result of getche() i.e. c.
farooqDeveloper wrote:
How to run this in VS2010.

This cannot run in VS2010.

Your program uses both something that was only available in Turbo C (far pointer, conio, etc) and something that was only available in MS-DOS (the BIOS keyboard state at 0x417).

25 years is an eternity in the world of computer programming, a lot of things from those days are not applicable today. A program that behaves this way on Windows, MacOS, or Linux would be totally different.
Last edited on
Topic archived. No new replies allowed.