Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Using gets() to read a string from the keyboard

#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