Why doesn't getchar() function work on Sololearn in C++ code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why doesn't getchar() function work on Sololearn in C++ code?

Am I missing something? In C code it works. https://code.sololearn.com/cnKiagl94j4P/?ref=app https://code.sololearn.com/ct1cSEV2l825/?ref=app

28th May 2021, 12:05 AM
Lofty
Lofty - avatar
3 Answers
0
I think it's some kind of bug. When you try: char c = getchar(); cout << c; cin >> c; cout << c; And send two separate inputs, it will work fine, so it may be just SoloLearns bug
28th May 2021, 12:15 AM
Michal Doruch
0
A.S. The problem is that you can't input anything in the C++ code. As author mentioned - In C code it works.
28th May 2021, 1:58 AM
Michal Doruch
- 2
Becz you not printing value that's why it showing no output use printf and cout it will work #include <stdio.h> int main() { //getchar(); printf("%c",getchar()); return 0; }
28th May 2021, 1:48 AM
A S Raghuvanshi
A S Raghuvanshi - avatar