• C

two easy questions

1. why doesn't the ascii character -> (right arrow) work.
   every ascii chart I have seen says that this is hex 1A
   but it will not work. I get the others to work but not    that one.
2 I am writing a dos program that has a menu. I have set up   borders around the menu no problem now I want to color the   menu. how do I color just the menu background and not the   whole screen.  
strmtrprAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mlaiosaConnect With a Mentor Commented:
All the ascii charcters below 32 (0x20) have special meanings and for that reason, many of them cannot be displayed on the screen using standard out.  1A is one such charcter.  It is the End of FIle (EOF) charcter.

to display *any* ascii charcter on a display that is not MGA or HGC, and to set the color of any signal charcter, use the folowing: (I assume you are using TC for dos):

#include <dos.h>

void putchar(int x, int y, char c)
//puts the charcter c at x,y on the screen.
{
  *(char far *)MK_FP(0xb800,2*(y*80+x))=c;
}

char putchar(int x, int y)
//returns the charcter at x,y
{
  return *(char far *)MK_FP(0xb800,2*(y*80+x));
}

void setattr(int x, int y, int attr)
//set the attribute attr at x,y
{
  *(char far *)MK_FP(0xb800,2*(y*80+x)+1)=attr;
}

int getattr(int x, int y)
//get the attribute at x,y
{
  return *(char far *)MK_FP(0xb800,2*(y*80+x)+1);
}


for all those functions, the upper left corner of the screen is 0,0  They do not move the cursor, or care where it is.
valid attributes are 0x00 .. 0xff

the first hex digit is the background color and the second is the forground color.

I would reccomend doing some experiments to find what 0..f values generate what values and make some defines, ex:

#define black 0
#define blue 1
#define green 2
#define cyan 3

so that you could do stuf like:

putattr(5,15,(black<<4)+green);  //this will generate green on black
0
 
strmtrprAuthor Commented:
thank you answering so quickly.

0
 
ozoCommented:
Actually, ASCII calls it the Substitute (SUB) character
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.