#include "stdio.h"
#include "conio.h"
#include "graphics.h"
char far *vidmem=0xB8000000;
main()
{

    int gm,gd=DETECT;
    int r,c,i;
    char message[]="praveen";
    initgraph(&gd,&gm,"");

    clrscr();
    for(r=5;r<=20;r++)
    {
        for(c=5;c<=50;c++)
            write2vdu('',64,r,c);
    }
    c=10;
    for(i=0;i<=10;i++)
    {
        write2vdu(message[i],77,10,c);
        c++;
    }
    getch();
}
write2vdu(char ch,char attr,int row,int col)
{
char far *v;
v=vidmem+row*160+col*2;
*v=ch;
v++;
*v=attr;
}

when i run this it just show only white screen..but the author of this program says tat will show a box with some texts..any one help me to get correct output.thankyou....

Recommended Answers

All 4 Replies

I can't get it to work, but I can see that it's close. This is with the C compiler in Turbo C/C++ ver. 1.01.

This uses direct video writing, and oddly, direct video writing still works with Windows XP (32 bit), as the operating system. That's for certain!

But I can't *quite* get this program to work as it should. (it should spell out "praveen", of course).

Can you double check with the source code that does work? See what differences there are?

it's k..i have one doubt in tat program..tat means in that top of the prgm we are using "char far *vidmem=0XB8000000;"
will u tell why we are using this..?wat is the use of tatline.?

That location in memory, should be for video memory, which the OS sets up for the display card. I did change it around a few times, but just 3-4 guesses, not a systematic search.

I don't know about the part that is here:

v=vidmem+row*160+col*2;

or about the attribute variable. For all I know, it could be writing up just fine, but writing up the letters in white, on a white background, so it's invisible.

I'll spend some more time with it today, but it's not looking really promising, right now. It's close, but close doesn't count for much, in programming.

OK, found the answer!

We can't DETECT the graphic driver integer - that sets the graphics system up to the wrong value.

This is the correct program:

#include "stdio.h"
#include "conio.h"
#include "graphics.h"
char far *vidmem=0xB8000000;  
main()
{

int gm, gd=1;  //gd=0 is the white screen that doesn't work, 1-4 are OK (for me)
int r,c,i;
char message[]="praveen";
initgraph(&gd,&gm,"");

clrscr();
for(r=5;r<=20;r++)
{
for(c=5;c<=50;c++)
write2vdu('',64,r,c);
}
c=10;
for(i=0;i<8;i++)     //<=10 goes outside the array
{
write2vdu(message[i],77,10,c);
c++;
}
getch();

}
write2vdu(char ch,char attr,int row,int col)
{
char far *v;
v=vidmem+row*160+col*2;
*v=ch;
v++;
*v=attr;
}

It would be nice to update the main() to int main() and add the return 0; at the end, and also make the write2vdu() function into a void function with a prototype.

Obviously, the memory location (although common), is not going to be "just right" for every system's set up. The display is a brilliant red square (half size of the monitor), with a magenta "praveen" printed on it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.