0

This program is to print name without using the header files

void main()
{
int i;
char far *s=(char far *)0xb8000000l ;
*(s+2)='p';
*(s+4)='r';
*(s+6)='i' ;
*(s+8)='i' ;
*(s+10)='t';
}

please explain the meaning of the line char far *s=(char far *)0xb8000000l ;

4
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by gagansharma
0

Put simply, it gives you a pointer to the starting address of text mode video memory. Since the address doesn't change, you can cast it to a pointer to char and assign to offsets from that pointer to write to the appropriate memory blocks.

0

Your code is alittle old. In old 16 bit systems like DOS 6.0 there is a different memory addressing system named "segment" and far mentioned how the pointer can access to segments. But in nowadays 32 bit systems addressing is not via segment so there is no need to mention far.

I mean you could re-write your program as below

void main()
{
int i;
char *s=(char *)0xb8000000l ;
*(s+2)='p';
*(s+4)='r';
*(s+6)='i' ;
*(s+8)='i' ;
*(s+10)='t';
}
0

>why this
>(char far *)0xb8000000l is used??
>please explain its meaning??
Did you not read my post? I already explained that:

Since the address doesn't change, you can cast it to a pointer to char

It's taking a literal address and casting it to a pointer to char.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.