About C programming-VDU memory

Is there something gone wrong in the below
program.Because when i execute this program i will get infinite output.Actually,I wrote this program for flipping the characters on the screen.I mean this program converts the small case letters into capital case letters & vice-versa infinite times present at a particular address so that the output appears as the characters flipping on the screen.But i didnt get this effect.Why?And on my pc windows-xp is installed & i use turbo c.
PROGRAM.
--------------------------
#include
#include
void main()
{
int i;
char far *s;
clrscr();

s=(char far *)0xB8000000;
while(1)
{
for(i=0;i<=3998;i+=2)
{
if(*(s+i)>='A' && *(s+i)<='Z')
*s=*s+32;
else
{
if(*(s+i)>='a' && *(s+i)<='z')
*s=*s-32;
}
}
}
}

Comments

  • Your program is stepping through screen memory, flipping all the lower case letters to upper case letters and vice versa. But it's doing that in an infinite loop. So you'll get some sort of funny result.

    What you need to do is to put in a pause after each pass through the screen, so that the video display can be updated, and the user can take in the result. Calling sleep() for one second will probably do the trick.

    Read my books
    [link=http://www.lulu.com/bgy1mm] MiniBasic how to write a script interpreter [/link]
    [link=http://www.lulu.com/bgy1mm] Basic Algorithms (in C) [/link]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion