How to solve this problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
using namespace std ;
int main ()
{
string s = "wish for my luck" , e= "thanks" , f ;
int x , n ;
cout<<s<<endl;
cout<<"anything to say? enter without space"<<endl;
cin>>f ;
cout<<f<<endl ;
n=f.length() ;
if (x=n)
cout<<e<<endl ;
system ("pause") ;
return 0 ;


the problem is when the people enter f with space cout<<f ; just print the first word, how to solve this problem?
getline(cin, f);
substitute with
cout<<f<<endl ; ?
getline is for input. You can look it up yourself using your search engine of choice.
Last edited on
thanks it's work, sorry for noob question I'm a newbie
Topic archived. No new replies allowed.