+ 1
Is it possible to get user input (cin) when my program is running in playground ?
6 Réponses
+ 3
Unfortunately not. It's one of my greatest hates against the code playground. The input system is terrible.
+ 2
I have same question.
If I run same code on a computer, I can input many times as the code requests, but on SoloLearn's compiler, I have to input all the numbers (or words, etc.) in a row before compiling.
I think we should interact with the code, not just ask it to work.
+ 1
Oh damn, was coding a more or less... Anyway thanks!
I'll release it and people may execute it in Visual 😂
+ 1
@Anita What do you mean ? Using an other way to ask for user input or update SoloLearn compiler ?
+ 1
Ok! Yeah it's annoying but maybe it will be changed in the future !
0
@Samy Let me explain my answer.
Here is a code:
int main () {
int name, age;
cout << "What's your name?\n";
cin >> name;
cout << "It's a good name.\n";
cout << "How old are you?\n";
cin >> age;
cout << "Oh, you're " << age << " years old.\n;
return 0;
}
If I run this code on a computer, I'll see:
What's your name?
(INPUT)Anita
It's a good name.
How old are you?
(INPUT)1000
Oh, you're 1000 years old.
But, if I run this code on SoloLearn's code playground, I'll see:
(INPUT)Anita
1000
What's your name?
It's a good name.
How old are you?
Oh, you're 1000 years old.
On a COMPUTER, it seems that my code can INTERACT WITH ME; but on SOLOLEARN'S CODE PLAYGROUND, my code is TALKING WITH ITSELF, and I think this phenomenon is weird.
To reply @Samy, there's no other way to ask for user input, so I hope SoloLearn can update its compiler.
Hope you won't think my explanation is too long.