fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. { char name[5][20];
  6. int count=0;
  7. cout << "Enter at most 4 names with at most 19 characters:\n";
  8. while (cin.getline(name[count++], 20))
  9. ;
  10. --count;
  11. cout << "The names are:\n";
  12. for (int i=0; i<count; i++)
  13. cout << "\t" << i << ". [" << name[i] << "]" << endl;
  14. }
Success #stdin #stdout 0s 4568KB
stdin
George Washington
John Adams
Thomas Jefferson
stdout
Enter at most 4 names with at most 19 characters:
The names are:
	0. [George Washington]
	1. [John Adams]
	2. [Thomas Jefferson]