taking string input in c++ gfg code example
Example: how to read a line from the console in c++
#include <string>
std::string str;
std::getline(std::cin, str);
// The output of std::getline(std::cin, str) will be stored in str.
#include <string>
std::string str;
std::getline(std::cin, str);
// The output of std::getline(std::cin, str) will be stored in str.