C,C++,SQL,PL/SQL Search Engine

Custom Search

Java, ebook Search Engine

Custom Search

Friday

Graphics video memory in c using far pointer




(b)Graphics video memory:

Segment number 0XA is known as graphics video memory. This segment has 720 columns and 400 rows.

Intersection of rows and columns is known as pixel. Size of each pixel is one byte which stores color information.

Example:

(q)What will be output of following c program?

#include "dos.h"
void main(){
int j;
union REGS i,o;
char far *ptr=(char *)0XA0000000;
i.h.ah=0;
i.h.al=0x13;
int86(0x10,&i,&o);
for(j=1;j<=100;j++){
*(ptr+j)=4;
}

}

Output: One red color line in the graphics console as shown in the following figure






In the above program what is following codes?

union REGS i,o;
i.h.ah=0;
i.h.al=0x13;
int86(0x10,&i,&o);

Answer:
The task of this code is to switch the 256 bit color graphics console window from default console window of Turbo c++ IDE.

More examples:

Copy the following code and execute the code in Turbo c compile and see what is displaying.

(1)What will be output of following c program?

#include "dos.h"
void main(){
int j,k;
union REGS i,o;
char far *ptr=(char *)0XA0000000;
i.h.ah=0;
i.h.al=0x13;
int86(0x10,&i,&o);
for(k=0;k<100;k++){
for(j=1;j<=319;j++){
*(ptr+j+k*320)=k;
}
}

}


(2)What will be output of following c program?

#include "dos.h"
void main(){
int j,k;
union REGS i,o;
char far *ptr=(char *)0XA0000000;
i.h.ah=0;
i.h.al=0x13;
int86(0x10,&i,&o);
for(k=0;k<100;k++){
for(j=1;j<=319;j++){
*(ptr+j+k*320)=k;
}
}

}

Wild pointer in c programming language.

2. Wild pointer:

A pointer in c which has not been initialized is known as wild pointer.
Example:

(q)What will be output of following c program?

void main(){
int *ptr;
printf("%u\n",ptr);
printf("%d",*ptr);

}

Output: Any address
Garbage value


Here ptr is wild pointer because it has not been initialized.
There is difference between the NULL pointer and wild pointer. Null pointer points the base address of segment while wild pointer doesn’t point any specific memory location.

3. File pointer:
To know about FILE pointer click here.

My Blog List