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 ;

Recommended Answers

All 5 Replies

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.

why this
(char far *)0xb8000000l is used??
please explain its meaning??

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';
}

>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 is the first address(first row and column) of VDU memory where we see output.

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.