how to ignore the [enter] key?

A

aguai

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
 
C

Colander

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top