Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Reading just one character from stdin

Name: Anonymous 2010-12-29 20:04

Learning some Java. I'm making a sort of brainfuck compiler out of boredom
http://en.wikipedia.org/wiki/Brainfuck
It's all done except the part where I have to read a byte from the standard input (works fine with bf programs that don't require input, even a cool ascii fractal generator i found).

So my question is, how can i read a single key from the keyboard? I could use a Scanner and make it read from System.in and take the first character, but the user would have to type something, which would appear on the screen, and then press enter, and that's not what I want.
I just want to read one character from the keyboard, without it appearing on the screen, and without the user having to press enter after it.

Any help?

Name: Anonymous 2010-12-29 20:39

Fuck off

Name: Anonymous 2010-12-29 20:40

I cant find `eval` and `read` functions in Java :-(

Name: Anonymous 2010-12-29 20:42

cbreak()

Name: Anonymous 2010-12-29 20:45

#include <termios.h>

        struct termios io;
        tcgetattr(0, &io);
        io.c_lflag &= ~ICANON;
        tcsetattr(0, TCSANOW, &io);

Name: Anonymous 2010-12-29 20:58

You guys are fucking useless

Name: Anonymous 2010-12-29 21:04

DURR HOW DO I UNDERSTAND HOW TERMINALS AND THEIR EMULATORS WORK

Name: Anonymous 2010-12-29 21:30

Just press Ctrl-d after you've entered the character you want instead of enter.

Name: Anonymous 2010-12-29 22:15

So how come the temperature conversion program thread with the most basic question in the world does get serious replies?

Name: Anonymous 2010-12-29 22:32

>>9

Because you're a moron?

Your question has been answered here and was answered several times in the thread you made at /g/, coupled with the fact that you could just easily Google this and get a simple answer makes people not want to respond to your thread.

Name: Anonymous 2010-12-29 23:08

>>10
How do you know there is a thread on /g/. Do you actually go there?

Name: Anonymous 2010-12-30 1:05

>>11
Yes. I also love importing memes from /b/ and /g/ to the delight of the denizens faggots of /prague/. lulz

Name: Anonymous 2010-12-30 7:36

>>11

Yeah, I do.

Name: Anonymous 2010-12-30 9:05

I just went to /g/. They discussed the bad ISP choices of their parents.

Name: Anonymous 2010-12-30 10:33

>>10
almost. It's because nobody who posted here knows the answer, except >>7 , or they wouldn't be saying it can be answered by a simple google search. but their ego is too weak to admit it.
If I come here and ask the absolute dumbest question in the world, I get a serious reply, but if I ask something nobody knows I get replies of the manner "your question is too dumb to deserve an answer"

Name: Anonymous 2010-12-30 10:58

System.in is (almost?) always going to be line-buffered when fed from a shell. There's no way around it short of messing with system-specific stuff. If you want unbuffered input then write a simple GUI and use a key listener.

Name: Anonymous 2010-12-30 11:02

>>15
The question has already been answered twice, you're just too dumb to understand it.  Go away.

Name: Anonymous 2010-12-30 11:44

>>17
I see only one half-answer.

Name: Anonymous 2010-12-30 12:41

>>18
You're not looking well enough.

Name: Anonymous 2010-12-30 13:18

>>19
Your gay.

Name: Anonymous 2010-12-30 13:56

>>20
What about my gay?

Name: Anonymous 2010-12-30 14:19

>>21
Yo'ure it is what.

Don't change these.
Name: Email:
Entire Thread Thread List