clreol() and clrscr() function not working
I already use lib <conio.h> but it still said clreol() was not declared in this scope.
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 90 91 92 93
|
#include<iostream>
#include<stdio.h>
#include<windows.h>
#include<ctime>
#include<conio.h>
#include<cstdlib>
using namespace std;
void gotoxy( int column, int line )
{
COORD coord;
coord.X = column;
coord.Y = line;
SetConsoleCursorPosition(
GetStdHandle( STD_OUTPUT_HANDLE ),
coord
);
}
int wherex()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
COORD result;
if (!GetConsoleScreenBufferInfo(
GetStdHandle( STD_OUTPUT_HANDLE ),
&csbi
))
return -1;
return result.X;
}
int wherey()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
COORD result;
if (!GetConsoleScreenBufferInfo(
GetStdHandle( STD_OUTPUT_HANDLE ),
&csbi
))
return -1;
return result.Y;
}
int main()
{
srand(time(NULL));
char KeyPress; //Key Press by user
int x=40;int y=10; //Establish initial position of cursor
char answer;
do{
cout<<"Doodler! Press I/J/K/M to move. Q to quit"<<endl;
do{
//Plot a "point"
gotoxy(x,y);
cout<<"*";
gotoxy(x,y); //move blinking cursor under current spot
KeyPress = getch(); //Get a key, not echoing to the screem
if (KeyPress==' '){
clreol();
}
if(KeyPress=='I'||KeyPress=='i')
y--;
else if (KeyPress=='M'||KeyPress=='m')
y++;
else if (KeyPress=='J'||KeyPress=='j')
x--;
else if (KeyPress=='K'||KeyPress=='k')
x++;
else if (KeyPress=='Q'||KeyPress=='q')
; //Do nothing
else
cout<<"\a"; //Beep for bad keystroke
}while((KeyPress!='Q')&&(KeyPress!='q'));
gotoxy(1,1); //Clear and display new little
clreol();
cout<<"Random stars! Press any key to stop."<<endl;
while(!kbhit()){
gotoxy(rand()%(60)+1,rand()%(20)+2);
cout<<"*"; //A star and a blank to draw AND erase
}
clreol();
cout<<"Do another game(N/Y)?";cin>>answer;
if ((answer=='y')||(answer=='Y'))
clrscr();
}while((answer=='y')||(answer=='Y'));
return 0;
}
|
They are not standard functions so I suppose you use compiler which simply have not them.
Perhaps it is better to avoid using non-standard extensions at all.
ok, i will have a try
thank you^-^
Topic archived. No new replies allowed.