0
How to take user input for char array that is a member of struct ? [Solved]
Uncomment those 3 lines in the following code and it works fine , and i have no idea about what is happening , so if anyone can explain ? Ty! https://code.sololearn.com/cYiSLulJj2M9/?ref=app
7 Respostas
+ 3
I think it's the .
#define Q X.m
cin.getline(Q,20);
works too without the dummy.
+ 4
This is a known SoloLearn issue. Not all input functions also trigger the input box, and some only do so with a specific syntax (for example, std::getline() requires no spaces between the parentheses and the arguments in order to trigger the input).
If necessary, a common workaround is to place a macro like the following somewhere in your code:
#define dummy std::cin >>
+ 2
I dunno, I guess Sololearn just takes your code and parses it to check if there is a cin or getline somewhere but it has problems if some characters get involved, probably.
+ 1
Shadow thank you .
+ 1
Shadow but char array defined in main function works fine without that macro , why so!
+ 1
Sorry, I don't know the reason for this behaviour either. My knowledge about how SoloLearn's IDE works under the hood is very limited.
0
Dennis why does that work ? And why it don't without it!