Using cin to read a string from the keyboard : string read « Data Types « C++ Tutorial






#include <iostream> 
using namespace std; 
 
int main() 
{ 
  char str[80]; 
 
  cout << "Enter a string: "; 
  cin >> str; // read string from keyboard 
  cout << "Here is your string: "; 
  cout << str; 
 
  return 0; 
}
Enter a string: string
Here is your string: string








2.25.string read
2.25.1.Using cin to read a string from the keyboard
2.25.2.Using gets() to read a string from the keyboard