Answer this question! | Sololearn: Learn to code for FREE!

+11

Answer this question!

Why it is not taking input? https://code.sololearn.com/c6rX0cImZglC/?ref=app Thanks!

c++ c

7 Answers

New Answer

+7

_ _ We need to take input using cin in cpp. Remove scanf and use cin like cin >> choice; https://code.sololearn.com/cVRnGFpbzRHM/?ref=app

+8

https://code.sololearn.com/cDZQN9946NVv/?ref=app

+5

Simba Then How this code working? C code in cpp? https://code.sololearn.com/cF4yofK03v2V/?ref=app

+2

Use cin instead of scanf

+2

this includes two problems. 1. the (original) code doesn't take inputs in code playground: nothing to add to I Am Groot ! 's answer. but you can use all c functions in c++. it's code-playground-specific. try in other environments. 2. even if it is rewritten as c code like Simba 's answer, it has a complication about how to separate multiple inputs: it's better not to mix scanf() and fgets() since scanf() doesn't read "\n" and fgets() read space as a character. the code below worked on cxxdroid, but with difficulty in controlling multiple inputs: #include <iostream> int main(int argc, char *argv[]) { int digit; char str[50]; scanf("%d",&digit); fgets(str,20,stdin); fgets(str,20,stdin); std::cout <<digit << " "<< str; }

+1

+1

You must take the input using "cin" and the output using "cout". That's the right in cpp