+ 8

Can we use printf scanf in c++?

If so then which header file do we need to use fir them? Please also tell the functioning of getch() in c++.

15th Sep 2017, 4:27 PM
Diwanshi Gupta
Diwanshi Gupta - avatar
5 Answers
+ 11
#include<stdio.h> us used for this. getch() is a nonstandard function and is present in conio.h header file which is mostly used by MS-DOS compilers like Turbo C. It is not part of the C standard library or ISO C, nor is it defined by POSIX (Source: http://en.wikipedia.org/wiki/Conio.h) It read's a single character from keyboard. But it does not use any buffer, so the entered character is immediately returned without waiting for the enter key. https://www.sololearn.com/Discuss/288609/?ref=app
15th Sep 2017, 4:55 PM
P R
P R - avatar
+ 3
Yes, using <cstdio> (stdio.h), you can use printf() and scanf(). getch(), a C based function from the conio.h library (a library now considered deprecated as it is only supported by windows, and was never standardised), is used to read a character, whatever it may be, from the console. It can only read a single character, and is used in the following way : char c = getch(); Note that the function takes no arguments. This function should not be used in the present times, and you may replace it by cin.get();
15th Sep 2017, 5:04 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
<cstdio> is to be used for printf and scanf. getch() is used to hold the output as in some compilers, output isn't visible as it terminates. Therefore getch() is used to hold the program so that we may see the output of program.
15th Sep 2017, 4:57 PM
Satyajit Sahoo
Satyajit Sahoo - avatar
0
use stdio.h for printf and scanf getch() is get character which reads a single character from thw keyboard but doesnt show up on screen and it is used with conio.h
15th Sep 2017, 4:53 PM
Suhail Pappu
Suhail Pappu - avatar
- 1
Devendra Yadav,you did,nt accept my challenges??? challenge storm me!!
25th Oct 2017, 2:18 PM
David Fernando
David Fernando - avatar