Reading more than one word


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #include <iostream> int main() {
  2. using namespace std; const int ArSize = 20; char name[ArSize]; char dessert[ArSize];
  3. cout << “Enter your name:\n”; cin.getline(name, ArSize); // reads through newline cout << “Enter your favorite dessert:\n”; cin.getline(dessert, ArSize);
  4. cout << “I have some delicious “ << dessert; cout << “ for you, “ << name << “.\n”; return 0;
  5. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.