Connecting Tech Pros Worldwide Help | Site Map

how to ignore the [enter] key?

  #1  
Old April 22nd, 2007, 04:25 PM
aguai
Guest
 
Posts: n/a
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

  #2  
Old April 22nd, 2007, 06:25 PM
Colander
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript/ change enter key to tab keypress rrosebro answers 8 July 17th, 2008 08:46 PM
Response.Redirect not working when pressing the Enter key nkoier@gmail.com answers 4 March 7th, 2007 06:45 PM
How do I make the enter key act like a button click? SJ answers 12 November 21st, 2005 04:07 PM
Need to ignore Enter key in Form Lars Netzel answers 1 November 19th, 2005 06:32 AM