Hello
I`m new to VC++,I tried to compile this code in VC++ but I couldn`t but when I did this in TC++ ,it was compiled with no problem.
#include
<conio.h>#include
<stdio.h>#include
<dos.h>void
goto_xy(int x , int y);void
main(){ void cls() ; register int x, y ;cls() ;
goto_xy(10, 10) ;
printf(
"this is a test.");getch();}
//*******************
void
goto_xy(int x , int y){
union REGS r ;r.h.ah = 2 ;
r.h.dl = y ;
r.h.dh = x ;
r.h.bh = 0 ;
int86(0x10, &r, &r) ;}
//*******************
void
cls(void){
union REGS r ;r.h.ah = 6 ;
r.h.al = 0 ;
r.h.ch = 0 ;
r.h.cl = 0 ;
r.h.dh = 23 ;
r.h.dl = 79 ;
r.h.bh = 7 ;
int86(0x10, &r, &r) ;}
and these are errors:
c:\vc programs\new\new\new.cpp(17) : error C2079: 'r' uses undefined union 'goto_xy::REGS'
c:\vc programs\new\new\new.cpp(18) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(18) : error C2228: left of '.ah' must have class/struct/union
c:\vc programs\new\new\new.cpp(19) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(19) : error C2228: left of '.dl' must have class/struct/union
c:\vc programs\new\new\new.cpp(20) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(20) : error C2228: left of '.dh' must have class/struct/union
c:\vc programs\new\new\new.cpp(21) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(21) : error C2228: left of '.bh' must have class/struct/union
c:\vc programs\new\new\new.cpp(22) : error C3861: 'int86': identifier not found
c:\vc programs\new\new\new.cpp(27) : error C2079: 'r' uses undefined union 'cls::REGS'
c:\vc programs\new\new\new.cpp(28) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(28) : error C2228: left of '.ah' must have class/struct/union
c:\vc programs\new\new\new.cpp(29) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(29) : error C2228: left of '.al' must have class/struct/union
c:\vc programs\new\new\new.cpp(30) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(30) : error C2228: left of '.ch' must have class/struct/union
c:\vc programs\new\new\new.cpp(31) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(31) : error C2228: left of '.cl' must have class/struct/union
c:\vc programs\new\new\new.cpp(32) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(32) : error C2228: left of '.dh' must have class/struct/union
c:\vc programs\new\new\new.cpp(33) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(33) : error C2228: left of '.dl' must have class/struct/union
c:\vc programs\new\new\new.cpp(34) : error C2228: left of '.h' must have class/struct/union
type is 'int'
c:\vc programs\new\new\new.cpp(34) : error C2228: left of '.bh' must have class/struct/union
c:\vc programs\new\new\new.cpp(35) : error C3861: 'int86': identifier not found
I
I think the reason was the dos.h header file.what can I do

How can I call BIOS Interrupts in VC++?
Kojacked
Hello Bardia.
Your real question seems to be, "How can I clear the screen and move the cursor" This question, has nothing to do with accessing interrupts. It's only in DOS where the way to clear the screen was to resort to the interrupts. Neither Windows, UNIX, MacOS X, BSD, OS/2, nor Linux make use of interrupts to clear the screen.
So let's answer your real question: "How do I clear the screen "
As noted in the C++ FAQ, there is no standard clrscr function available to you. It told you to consult the compiler documentation for more information. In Visual C++, the way to clear the screen is to use the Console::Clear() function. (.NET must be enabled).
If you're not allowed to use .NET, then you can make use of system("cls");.
Performing the gotoxy() however, requires more trickery (cannot be done with C++ alone, it requires .NET or Win32).
The Markus
Hello Oshah.
so how can I use REGS union,in86(),bdosptr,bdos,intdos function existed in dos.h header file
int86( int intnum,union REGS *in,union REGS *out)
int intdos(union REGS *in,union REGS *out)
int bdos(int fnum,unsigned dx,unsigned al)
int bdosptr(int fnum,void *dsdx,unsigned al)
struct WORDREGS{
unsigned int ax,bx,cx,dx,si,di,cflag,flags;
}:
struct BYTERREGS{
unsigned char al,ah,bl,bh,cl,ch,dl,dh;
};
union REGS{
struct WORDREGS x;
struct BYTERREGS h;
};
struct SREGS{
unsigned int es;
unsigned int cs;
unsigned int ss;
unsigned int ds;
};
struct REGPACK{
unsigned r_ax,r_bx,r_cx,r_dx;
unsigned r_bp,r_si,r_di,r_ds,r_es,r_flag;
};
for example in these programs:
#include
<stdio.h>#include
<conio.h>#include
<dos.h>void
set_palette(int palette, int color);void
main(){
int p, color;set_palette(p, color);
getch();
}
//********************
void
set_palette(int palette, int color){
union REGS in, out;in.h.ah = 0x0B;
in.h.bh = palette;
in.h.bl = color;
int86(0x10, &in, &out);
}
or:
#include
<stdio.h>#include
<conio.h>#include
<dos.h>void
dir_list() ;void
main(){
dir_list();
getch();
}
//********************
void
dir_list(){
union REGS in, out ; char pp[44] ;bdosptr(0x1a, pp, 0) ;
bdosptr(0x4e,
"*.*", 0) ;printf(
"\n %s \n", &pp[30]) ; for(;;) { if(bdos(0x4f, 0, 0) == 18) break ;printf(
"\n %s \n", &pp[30]) ;}
//end of for}
and the errors for the second:
c:\vc programs\new\new\new.cpp(13) : error C2079: 'in' uses undefined union 'dir_list::REGS'
c:\vc programs\new\new\new.cpp(13) : error C2079: 'out' uses undefined union 'dir_list::REGS'
c:\vc programs\new\new\new.cpp(15) : error C3861: 'bdosptr': identifier not found
c:\vc programs\new\new\new.cpp(16) : error C3861: 'bdosptr': identifier not found
c:\vc programs\new\new\new.cpp(19) : error C3861: 'bdos': identifier not found
Sudha
There is no way to do this under Windows. The acess to the BIOS is protected.
There is no way to execute BIOS functions from within a Win32 application. Use the Win32 API
satheeshkumarana
Let's tackle these questions one by one. (All assume .NET is available... if you can't use .NET, let me know, and I'll give Win32 solutions).
Q1. How do we set the console foreground and background color
Console::BackgroundColor = ConsoleColor::DarkMagenta;
Console::ForegroundColor = ConsoleColor::White;
Q2. How do we get a listing of all files in a folder
Either system("dir C:\\YourDir\\*.*"); or:
array<String ^> filelist = System::IO::Directory::GetFiles(L"C:\\Yourdir", L"*.*");
int i = 0;
for each(String ^filename in filelist)
{
Console::WriteLine("FileName {0} = {1}", ++i, filename);
/* Do what you want to the file here... */
}
Any other function