+ 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";
8 Réponses
+ 6
getline(cin,a)
+ 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.
+ 5
Make this Code Public and i will try it and tell you the Answer
+ 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.
+ 5
thank youu <3 ^_^
+ 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)
+ 3
The cin statement stops execution when it encounters blank spaces. To avoid this problem use getline (cin, a)