|
From: <and...@su...> - 2003-06-09 16:47:08
|
Dear Users,
Concerning the Esc escape sequence on the following while, let me report
my exact problem:
In C, this works:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char tecla='x';
do
{
printf(" the key is-->%c\n", tecla);
}while((tecla = getche())!= 27);
system("pause");
return 0;
}
I´ve changed the getchar by the getche() function and It worked.
But, with the following code:
#include <iostream>
#include <cstdlib>
using std::cout;
using std::endl;
using std::cin;
int main()
{
char tecla='x';
do
{
cout << " not escaped yet!!! " << endl;
}while(tecla = cin.get()!= 27);
system("pause");
return 0;
}
--> The behavior of cin.get() seems to me equivalent to getchar(). And the
getchar() function stores on the 1st time the caracter and on the second the
'\n'. And, it doesn´t escape when
I press the Esc key, ok?
--> What I need is way to write this second program working the same way as
its previous above.
Regards
Andre
|