Compiler is dev c++ 6.3 and OS is windows10
There is one problem with displaying a character that has code number 219. Console application doesn't display it but shows some blue lines instead at the end of string(and red at the begining).
At the begining it works fine, but after using "SetConsoleTextAttribute(console, 0x07);" (I assume) it starts to show this blue lines.
What is important is function "draw_cursor()".
I also send printscreen of output.
Output: problem.jpg
Code: problem.txt
http://infinityhost.cba.pl/problem.txt
http://infinityhost.cba.pl/problem.jpg
The code is:
include <stdio.h>
include <string.h>
include <conio.h>
include <windows.h>
include <iostream>
using namespace std;
char tab[10][30]; // an array of names
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); // console handle
// placing cursor into new position
void gotoxy(short x, short y) {COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);}
// hiding cursor
void hidecursor(){
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO info;
info.dwSize = 100;
info.bVisible = FALSE;
SetConsoleCursorInfo(consoleHandle, &info);}
void draw_cursor(int pos){
SetConsoleOutputCP(850);
SetConsoleTextAttribute(console, 0x07);
int poz=2;
for(int i=0;i<9;i++){
gotoxy(2,poz+i);
printf("%s",tab[i]);}
gotoxy(2,pos+2);
SetConsoleTextAttribute(console, 0x70);
// PROBLEM !!!!
// DOESN'T DISPLAY 219 CHARACTER BUT BLUE LINES
for(int u=2;u<18;u++){
gotoxy(u,pos+2);
printf("%c",219);
//cout<<(unsigned char)219; doesn't work also
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
gotoxy(2,pos+2);
printf("%s",tab[pos]);}
void draw_frame(){
short start_x,start_y;
start_x=1;start_y=8;
// upper horizonttal
gotoxy(start_x,1);printf("%c",201);gotoxy(25,1);printf("%c",187);
for(int i=0;i<24;i++){gotoxy(i+start_x,1);printf("%c",205);}
gotoxy(start_x,1);
printf("%c",201);
// lower horizontal
gotoxy(start_x,1+10);
printf("%c",200);
gotoxy(25,1+10);
printf("%c",188);
for(int i=0;i<24;i++){gotoxy(i+start_x,1+10);printf("%c",205);}
gotoxy(start_x,1+10);
printf("%c",200);
for(int i=1;i<10;i++){gotoxy(start_x,i+1);printf("%c",186);gotoxy(start_x+24,i+1);printf("%c",186);}}
void prepare_an_array(){ strcpy(tab[0],"Charlie");
strcpy(tab1,"John");
strcpy(tab2,"Mike");
strcpy(tab[3],"Robert");
strcpy(tab[4],"Thomas");
strcpy(tab[5],"Endriu");
strcpy(tab[6],"James");
strcpy(tab[7],"Lucas");
strcpy(tab[8],"Bradley");}
int main()
{
hidecursor();
char z;
int position=0;
prepare_an_array();
draw_frame();
draw_cursor(0);
do{
z=getch();
if(z!=27){
if(z==80 && position<8){position++;draw_cursor(position);}
if(z==72 && position>0){position--;draw_cursor(position);}}
}while(z!=27);
return 0;
}