Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > how to ignore the [enter] key?

Reply
Thread Tools

how to ignore the [enter] key?

 
 
aguai
Guest
Posts: n/a
 
      04-22-2007
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

 
Reply With Quote
 
 
 
 
Colander
Guest
Posts: n/a
 
      04-22-2007
On Apr 22, 5:15 pm, aguai <(E-Mail Removed)> wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
ignore outlook users Skratz Firefox 8 05-05-2005 07:15 PM
Ignore/Kill-file in Thunderbird newsreader Ranjit Firefox 1 08-20-2004 05:19 AM
Ignore + TEST + Ignore SpooderStank Computer Support 2 04-08-2004 11:26 AM
Searching for Exact Phrase - should I ignore the ignore words? Rob Meade ASP General 6 03-01-2004 11:28 AM



Advertisments