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

3rd Mar 2021, 3:19 PM
Abhay
Abhay - avatar
7 odpowiedzi
+ 3
I think it's the . #define Q X.m cin.getline(Q,20); works too without the dummy.
3rd Mar 2021, 3:59 PM
Dennis
Dennis - avatar
+ 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 >>
3rd Mar 2021, 3:25 PM
Shadow
Shadow - avatar
+ 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.
4th Mar 2021, 3:42 PM
Dennis
Dennis - avatar
+ 1
Shadow thank you .
3rd Mar 2021, 3:28 PM
Abhay
Abhay - avatar
+ 1
Shadow but char array defined in main function works fine without that macro , why so!
3rd Mar 2021, 3:36 PM
Abhay
Abhay - avatar
+ 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.
3rd Mar 2021, 3:46 PM
Shadow
Shadow - avatar
0
Dennis why does that work ? And why it don't without it!
4th Mar 2021, 11:21 AM
Abhay
Abhay - avatar