Connecting Tech Pros Worldwide Help | Site Map

how to ignore the [enter] key?

 
LinkBack Thread Tools Search this Thread
  #1  
Old April 22nd, 2007, 03:25 PM
aguai
Guest
 
Posts: n/a
Default how to ignore the [enter] key?

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, 05:25 PM
Colander
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.