i would like to know the way we can make user enter a number in a menu reply perhaps so that he doesnt have to press the enter key...........i.e. the program automatically proceeds with the give value and doesnt wait for an enter key to be pressed. its easy in foxpro but i dont know the way to do it in C.

Recommended Answers

All 3 Replies

i would like to know the way we can make user enter a number in a menu reply perhaps so that he doesnt have to press the enter key...........i.e. the program automatically proceeds with the give value and doesnt wait for an enter key to be pressed. its easy in foxpro but i dont know the way to do it in C.

use getch()

use getch()

Just be wary that the getch() function and the associated conio.h header file are not portable.

i would like to know the way we can make user enter a number in a menu reply perhaps so that he doesnt have to press the enter key

For this question we need to know what compiler and OS you use because there are no portable answers that will work everywhere. The answer needs to be tailored to your setup.

Just be wary that the getch() function and the associated conio.h header file are not portable.

This caveat applies to every solution because the problem itself is not portable. There is no standard way in C to read input without the possibility of buffering at a higher level. It is a system dependency.

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.