tags:

views:

76

answers:

2

Yersterday I was trying to create a text editor in c. but i am facing a problem with the backspace character. and when i am trying to print this with outtextxy a strange character is appearing. i tried following code for this backspace:

str[2]="\b ";

outtextxy(x,y,str);

This is working fine under textmode but not working under graphics mode. If you r having any solution please help me I hav to submit my program on monday.

And Thanks in advance

+1  A: 

That's been a good 20 years since I last laid eyes on that. It is a low-level graphics output function in BGI (IIRC). You'll get the glyph for code 8, a rectangle with a circle in the OEM character set.

To make it act like, say, puts(), you'll have to interpret the control codes yourself. If you see a backspace (char 8), you'll have to update your internal "cursor position" variable and move x back by the font width. Same for '\n' (increment y) and '\r' (set x to 0).

Hans Passant
A: 

Since U are in Graphics mode:

  1. [STEP 1] Keep track of current position using two ints (say x,y)

  2. [STEP 2] Whenever backspace is pressed:

    1st Check if x==0,y==0 : Emit a beep;

    Else check if x==0, y>0 : Then make x= screen-width, y=y-1;

    Else check if x>0, y>0 : Then x=x-1;

Now That U hav the right x,y co-ordinates, just outtextxy a NULL/space character at the position.

NOTE: After outtextxy do NOT increment x as the cursor is still supposed to be at the prev character position.

GOOD LUCK!!

CVS-2600Hertz