1234567891011121314
#include <iostream> using namespace std; int main() { string word4; cout << "Please enter a country: " << endl; cin >> word4; }
123456789101112131415161718192021
#include <iostream> #include <string> int main() { const int SIZE { 80 }; char country_cstr[SIZE]; std::cout << "Enter the country name: "; std::cin.getline(country_cstr, SIZE); std::cout << "You entered: " << country_cstr << "\n\n"; std::string country_str; std::cout << "Enter the country name: "; std::getline(std::cin, country_str); std::cout << "You entered:" << country_str << '\n'; }
Enter the country name: United Kingdom You entered: United Kingdom Enter the country name: Sierra Leone You entered:Sierra Leone