gagandeep_1984
asked on
Writing to VDU memory
Why my program coding is ineffective to display the characters on the screen using VDU memory?
The coding is given as below:
/* printing the integers stored in an array */
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
char far *video;
*video=0xB8000000; /* for VGA/EGA/CGA type */
int k, array[4]={ 1,2,3,4 };
for(i=0,k=0; k<=4; i+=2,k++)
{
*(video+i)=array[k]; /* adding text */
*(video+i+1)=65; /* adding attributes (colors) */
}
getch();
}
Please help!
The coding is given as below:
/* printing the integers stored in an array */
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
char far *video;
*video=0xB8000000; /* for VGA/EGA/CGA type */
int k, array[4]={ 1,2,3,4 };
for(i=0,k=0; k<=4; i+=2,k++)
{
*(video+i)=array[k]; /* adding text */
*(video+i+1)=65; /* adding attributes (colors) */
}
getch();
}
Please help!
hi
a few errors in your code
/* printing the integers stored in an array */
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
char far *video;
video=0xB8000000; /* for VGA/EGA/CGA type */ //it should be video and not *video
int k, array[4]={ 1,2,3,4 };
for(i=0,k=0; k<=4; i+=2,k++)
{
*(video+i)=array[k] + '0'; /* adding text */ //Here ascii value of zero is added to print correctly
*(video+i+1)=65; /* adding attributes (colors) */
}
getch();
}
Dhyanesh
a few errors in your code
/* printing the integers stored in an array */
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
char far *video;
video=0xB8000000; /* for VGA/EGA/CGA type */ //it should be video and not *video
int k, array[4]={ 1,2,3,4 };
for(i=0,k=0; k<=4; i+=2,k++)
{
*(video+i)=array[k] + '0'; /* adding text */ //Here ascii value of zero is added to print correctly
*(video+i+1)=65; /* adding attributes (colors) */
}
getch();
}
Dhyanesh
ASKER
Dear grg99,
Sorry, but I have a very less knowledge about memory model but the complier, which I am using is the " Turbo-c 3.0" .
Sorry, but I have a very less knowledge about memory model but the complier, which I am using is the " Turbo-c 3.0" .
The program modified by me works fine under Turbo-c 3.0
ASKER
Dear Dhyanesh,
Sorry for the late response.
According to your coding, I compiled the program but it shows an error " Cannot convert ' unsigned long' to 'char far' " at that point where you were insisting to remove the pointer from the statement ( video=0xB8000000; ) . But when the pointer is used in that statement, the concerned error vanish. After compiling the program, I see nothing on screen . Am I doing something wrong?
Please help!
Gagan...
Sorry for the late response.
According to your coding, I compiled the program but it shows an error " Cannot convert ' unsigned long' to 'char far' " at that point where you were insisting to remove the pointer from the statement ( video=0xB8000000; ) . But when the pointer is used in that statement, the concerned error vanish. After compiling the program, I see nothing on screen . Am I doing something wrong?
Please help!
Gagan...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dear Dhyanesh ,
Thank you for your help to make this program a success.
The statement which you have given stated as " video=(char far *) B8000000; " makes the program works fine.
But why does it gives a background of RED color? and also the value B0000000 given by you runs under monochorme video mode but mine is VGA mode.
Thank you for your help to make this program a success.
The statement which you have given stated as " video=(char far *) B8000000; " makes the program works fine.
But why does it gives a background of RED color? and also the value B0000000 given by you runs under monochorme video mode but mine is VGA mode.
hi
Sorry about the value B000000 it was a typing mistake. The value should be 0xB8000000.
Also if you want the text in red change following statement.
*(video+i+1)=RED; /* adding attributes (colors) */
Dhyanesh
Sorry about the value B000000 it was a typing mistake. The value should be 0xB8000000.
Also if you want the text in red change following statement.
*(video+i+1)=RED; /* adding attributes (colors) */
Dhyanesh
What compiler and memory model are you using?