+ 4

How to use gets() in cpp

these days I am learning strings and arrays in cpp. In my school they taught us to take a string as user input, one have to use gets() but it isn't working on any of the compilers I have. I have already tried using cstdio library, still errors. I know cin.getline() but it is a bit bigger word. plz help edit::: I forgot HAPPY CHRISTMAS TO ALL OF YOU!!!🌟💫🎄🎍🎊 ENJOY AANNNNDDD PARTY HARD!!!🎅

25th Dec 2017, 5:50 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
5 odpowiedzi
+ 6
getline(cin,variable); Is my way of getting input with spaces https://code.sololearn.com/cp32oQ9205NP/?ref=app
25th Dec 2017, 6:19 AM
Manual
Manual - avatar
25th Dec 2017, 6:16 AM
Manual
Manual - avatar
+ 5
I agree with @Gordie . Do not use gets. cin>> is better in cpp
25th Dec 2017, 6:18 AM
Qwqwq Rt
Qwqwq Rt - avatar
+ 2
thnx @gordie manual I tried scanf() in ur code but it takes spaces as termination just like cin thnx for ur help
25th Dec 2017, 6:21 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
- 1
another problem SL doesnt recognise cin.get i have to use cin.getline
26th Dec 2017, 5:52 AM
Saurabh Tiwari
Saurabh Tiwari - avatar