+ 4

#include <iostream> #include<string> using namespace std; int main() { string a; cin>>a; cout<<a; return 0; }

can anyone tell me why when i input something_ spaces dont work?? what should i use??? like if i inputed : "beautiful day"; it will cout "beautiful";

9th Mar 2017, 4:09 PM
SIGMA
SIGMA - avatar
7 Respostas
+ 6
getline(cin,a)
12th Mar 2017, 12:09 PM
NightX
NightX - avatar
+ 5
Because in the Sololearn Compiler When you Enter a Space it means that you will input another Variable if you want it to be showed correctly Write it like this: (beautiful_day) as an Example.
9th Mar 2017, 4:15 PM
Michael Ehab Mikhail
Michael Ehab Mikhail - avatar
+ 5
Make this Code Public and i will try it and tell you the Answer
9th Mar 2017, 4:18 PM
Michael Ehab Mikhail
Michael Ehab Mikhail - avatar
+ 5
Ok Sigma Try This Code it will Show it Correctly : #include <iostream> #include <string> using namespace std; int main(){ string a; string b; cin >> a; cin >> b; cout << a <<" "<<b; ----------------------------------------- a as the first word you enter and b for the second.
9th Mar 2017, 4:24 PM
Michael Ehab Mikhail
Michael Ehab Mikhail - avatar
+ 5
thank youu <3 ^_^
9th Mar 2017, 4:28 PM
SIGMA
SIGMA - avatar
+ 3
dear sigma, input entered through cin object is terminated as user presses space. In order to read space as the part of input, instead of cin>>a statement use cin.getline (a,80)
9th Mar 2017, 4:38 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
+ 3
The cin statement stops execution when it encounters blank spaces. To avoid this problem use getline (cin, a)
27th Mar 2017, 7:54 AM
Vishnu ks
Vishnu ks - avatar