Search This Blog

Friday, December 30, 2011

Use get() to read a string that contains spaces

Use get() to read a string that contains spaces

#include  
#include  
using namespace std; 
 
int main() 

  char str[80]
 
  cout << "Enter your name: "
  cin.get(str, 79)
 
  cout << str << '\n'
 
  return 0
}
Enter your name: Joe
Joe

No comments:

Post a Comment

Thank you