Using gets() to read a string from the keyboard : string read « Data Types « C++ Tutorial






#include <iostream> 
#include <cstdio> 
using namespace std; 
 
int main() 
{ 
  char str[80]; 
 
  cout << "Enter a string: "; 
  gets(str); // read a string using gets() 
  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