Connecting Tech Pros Worldwide Forums | Help | Site Map

how to ignore the [enter] key?

aguai
Guest
 
Posts: n/a
#1: Apr 22 '07
hi Im trying to do is something should be simple:
I wish to ignore the [enter] key....'\n'
my test is Like this

/*di.cpp*/
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(void)
{
setvbuf(stdin, NULL, _IONBF, 0);
while ( cin.peek()!='\n'){cout.put(cin.get())<<endl;}
return 0;

}

then I try
aguai@home:~/cpp$ ./a.out
please dont...
p
l
e
a
s
e

d
o
n
t
..
..
..

but what i hope is like
aguai@home:~/cpp$ ./a.out
p
l
e
a
s
e

d
o
n
t
..
..
..
<push enter and exit....>

is that possible to be done with a ansi C/C++ function?
thanx


Colander
Guest
 
Posts: n/a
#2: Apr 22 '07

re: how to ignore the [enter] key?


On Apr 22, 5:15 pm, aguai <henac...@gmail.comwrote:
Quote:
hi Im trying to do is something should be simple:
I wish to ignore the [enter] key....'\n'
my test is Like this
>
/*di.cpp*/
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(void)
{
setvbuf(stdin, NULL, _IONBF, 0);
while ( cin.peek()!='\n'){cout.put(cin.get())<<endl;}
return 0;
>
}
>
then I try
aguai@home:~/cpp$ ./a.out
please dont...
p
l
e
a
s
e
>
d
o
n
t
.
.
.
>
but what i hope is like
aguai@home:~/cpp$ ./a.out
p
l
e
a
s
e
>
d
o
n
t
.
.
.
<push enter and exit....>
>
is that possible to be done with a ansi C/C++ function?
thanx
(Deleted follow-ups)

I believe you are searching for 'noecho' which is in curses.h

Closed Thread