0
A doubt about getch() function
I just have a doubt about the usage of getch(); in a simple program to print a text. When I am giving the code as https://code.sololearn.com/cb3N8vMDnqr4/?ref=app I m not getting o/p in o/p console. And, when I am using a getch(); I am able to see the o/p like in the code https://code.sololearn.com/cbJh6s8ozUNg/?ref=app . Also, when the return type of the main() is int AND only if I use a getch() I am able to see the o/p like in the code https://code.sololearn.com/cKa3zVBSDtXS/?ref=app. Can u help me with this Guys. Thanks in advance
4 Answers
+ 1
use getchar(); instead of getch();
and write printf line after getchar();
+ 1
Mayank Dhillon
I tried it, after inputting a character, the control is coming back from o/p console to editor. I am using Turbo C by the way.
+ 1
You want to print the line after entering the character right?
#include <stdio.h>
int main()
{
printf("Hi");
getch();
return 0;
}
I used this one in sololearns compiler and it worked fine for me as intended, can't say about turboC because I mostly use CodeBlocks for C.
0
Mayank Dhillon Yes, I understood it now. Thank u.