Hi all.
Just a quick question for anyone who might know. Is there any way of setting up the entering of a character or number without having to press the return key after? For all options i input into my program when i run it i always have to press the return key after. I was just wondering if it was possible to have it so when the character or number is entered it automaticaly carries on without pressing the return key. It would help improve my program.
Thanks everyone :)

There is no standard C or C++ way to do that. There are a couple non-standards methods, depending on the operating system. For MS-Windows compilers you might look to see if your compiler supports conio.h. It has functions such as kbhit() that checks to see if something is available at the keyboard. Then there's curses, pdcurses and ncurses which are three versions of the same library and available on both MS-Windows and *nix.

Member Avatar for TEDickey

There is no standard C or C++ way to do that. There are a couple non-standards methods, depending on the operating system. For MS-Windows compilers you might look to see if your compiler supports conio.h. It has functions such as kbhit() that checks to see if something is available at the keyboard. Then there's curses, pdcurses and ncurses which are three versions of the same library and available on both MS-Windows and *nix.

That would be "implementations" rather than "versions". The term "versions" implies that they're derived from a common source. (I don't recall a recent "curses" library on MS-Windows which wasn't one of the other two).

That would be "implementations" rather than "versions". The term "versions" implies that they're derived from a common source. (I don't recall a recent "curses" library on MS-Windows which wasn't one of the other two).

Yea, right. "implementations" would have been a better choice of words.

And it's not dependent on the operating system. It depends on the compiler.

And it's not dependent on the operating system. It depends on the compiler.

Pick on AD day ??? It will actually depend both on OS and compiler. AFAIK *nix can't support the functions in conio.h, but I suppose someone could write a vt100 version or one that uses termcap.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.