English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

while writing programs we will write getch() before closing the programs what is the need of writing what happens if we dont write that

2006-12-25 23:11:33 · 10 answers · asked by lakshman kumar 1 in Computers & Internet Programming & Design

10 answers

Writing it at the end of a program is to clear the standard input buffer.
///

2006-12-25 23:13:38 · answer #1 · answered by jan 7 · 3 2

Well, the answers given by some other nice guys on your question are not accurate..

Actually getch() is a character input function. It is used to input a single character from the standard input device ( ie. Keyboard).
When you give the input (ie press any key), it does not echo that character onto the screen..

Just try and execute the following code..

#include
#include

main()
{
char var;
while( (var=getch()) != 'q')
putch(var);
}

The above code will continue executing until you press 'q'. Thus it is the terminating condition for the while loop.

putch() function is used to output a single character onto the screen. Instead, You can also use printf() or putchar() .

When we use getch() at the end of any program ( 99.99% of the learners do this without knowing the actual reason), it is actually specifying that the program will not continue until you press a single key stroke.ie until you give some input..You can use any input function like scanf() or getchar() or getche() instead of getch(). It will also do the same thing for you but these functions echo that character on the screen...thatz y we prefer using getch().

It has nothing to do with controlling the output screen from closing
after the program has executed successfully. getch() can be used anywhere in the program..

2006-12-26 21:00:12 · answer #2 · answered by Anonymous · 0 0

In Conceptual Matter getch() Gives The Sign Of Completion Of Programme It Gets character Input And Terminate Programme But Doesn't echo To The Console.

2006-12-26 18:49:54 · answer #3 · answered by dhvtzala 2 · 0 0

.
Nothing spl with that, simple.

You write a program with out getch() at the end. Now run the program. you could not see the output. To see the output, you have to press Alt+F5 (in Turbo C editor).

If you give getch() at the end of a program, after displaying the output, the screen will wait to get a character as input from you. Now you can see your output. when you are finished you will enter some character and the output screen will go.

thatz it.

**********
Vasu M
**********

2006-12-26 23:58:13 · answer #4 · answered by V@su Maniram 3 · 0 0

The most common use is to keep the program window from closing when you run it in the Windows IDE.

2006-12-25 23:16:19 · answer #5 · answered by Yanni 1 · 2 0

getch() works to display a programme on the screen. without this function u can not see the programme on screen.

2006-12-25 23:17:37 · answer #6 · answered by Anonymous · 0 1

The real answer is for getting Character from input devices

2006-12-25 23:36:18 · answer #7 · answered by nett 1 · 0 1

getch() is used to get input from console but it doesn't output that to screen.

2006-12-25 23:33:07 · answer #8 · answered by Get to Know 2 · 0 1

To find a brief note about this command and to know anything in C, click here

http://www.aasted.org/gc/c-tut.php...
For any tech queries:

http://dexter-laboratory.blogspot.com/...

2006-12-25 23:29:07 · answer #9 · answered by Dexter 2 · 0 1

while u use getch() the characters u typed would be stored contained in the variable after u press key enter.....yet in getche()....they are going to be stored the 2nd u variety unmarried character

2016-12-18 19:13:20 · answer #10 · answered by ? 4 · 0 0

fedest.com, questions and answers