Posted By

marwac6 on 02/21/11


Tagged

input array strings getline


Versions (?)

Reading more than one word


 / Published in: C++
 

  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  

You need to login to post a comment.