where i can find from conio.h the rest of files?

Hello.
I am trying to scan keyboard chars with getch().

1
2
3
4
5
6
7
 char ch;
       string password;
       while ( (ch = getch()) != '\r' )
       {
             password.push_back(ch);
       }
       cout<< "You entered :"<< password<<endl;


But where i can find from conio.h, the termios.h, etc. for DOS. I am working in a console with Code::Blocks, and WinXP.
libconio-1.0.0 is the library that i use.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/****************************************************
// conio.h
Libconio 1.0 (C) 2004 FSL A.C.

Basado en la implementacion de conio.h escrita
por Salvador Fernandez Barquin y adaptado a lib
por Maximo Pech Jaramillo <makz@linuxmail.org>

Se permite su uso, copia, distribucion y modificacion
bajo los tιrminos de la GNU GPL versiσn 2.0 publicada
por la Free Software Foundation.

*****************************************************/

#ifndef _CONIO_H
#define _CONIO_H

#ifndef _TERMIOS_H
#include "termios.h"
#endif
#ifndef _STDIO_H
#include <stdio.h>
#endif

#define ESC 033 /* Escape char */

struct textinfo
{
 int curx;
 int cury;
};

enum
{
 BLACK,
 RED,
 GREEN,
 BROWN,
 BLUE,
 MAGENTA,
 CYAN,
 LIGHTGRAY,
 DARKGRAY,
 LIGHTRED,
 LIGHTGREEN,
 YELLOW,
 LIGHTBLUE,
 LIGHTMAGENTA,
 LIGHTCYAN,
 WHITE,
};

int getche(void);
int getch(void);
void clreol(void);
void clrscr(void);
void gotoxy(int, int);
void textcolor(int);
void textbackground(int);
int wherex(void);
int wherey(void);

#endif


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/****************************************************
// conio.c
Libconio 1.0 (C) 2004 FSL A.C.

Basado en la implementacion de conio.h escrita 
por Salvador Fernandez Barquin y adaptado a lib 
por Maximo Pech Jaramillo <makz@linuxmail.org>

Se permite su uso, copia, distribucion y modificacion 
bajo los tιrminos de la GNU GPL versiσn 2.0 publicada 
por la Free Software Foundation.

*****************************************************/

#include "conio.h"

struct textinfo text={0, 0};

int getche()
{
        struct termios t;
        int c;

	tcgetattr(0,&t);
        t.c_lflag&=~ICANON;
        tcsetattr(0,TCSANOW,&t);
        fflush(stdout);
        c=getchar();
        t.c_lflag|=ICANON;
        tcsetattr(0,TCSANOW,&t);
        return c;
}

int getch()
{
        struct termios t;
        int c;

        tcgetattr(0,&t);
        t.c_lflag&=~ECHO+~ICANON;
        tcsetattr(0,TCSANOW,&t);
        fflush(stdout);
        c=getchar();
        t.c_lflag|=ICANON+ECHO;
        tcsetattr(0,TCSANOW,&t);
        return c;
}

void gotoxy(int x, int y)
{
printf("%c[%d;%dH", ESC, y, x);
text.curx = x;
text.cury = y;
}

void clreol()
{
printf("%c[K", ESC);
}

void clrscr()
{
printf("%c[2J", ESC);
gotoxy(0, 0);
}

void textcolor(int color)
{
if(color >= BLACK && color <= LIGHTGRAY ) /* dark color */
 printf ("%c[0;%dm", ESC, 30+color);
else	
 printf("%c[1;%dm", ESC, 30+(color-8));
}

void textbackground(int color)
{
printf ("%c[%dm", ESC, 40+color);
}
 
int wherex(void)
{
 return text.curx;
}

int wherey(void)
{
 return text.cury;
}


Thank's
Last edited on
I think this is part of turbo c.. but they doesnt seem to be part of standard c and may not be included in any compiler.
Topic archived. No new replies allowed.