fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4. int main()
  5. {
  6. unsigned nBills;
  7.  
  8. std::cout << "How many bills will you enter?\n";
  9. std::cin >> nBills;
  10.  
  11. std::string* bills = new std::string[nBills];
  12.  
  13. std::cout << "Please enter the bill names.\n";
  14.  
  15. std::cin >> std::ws ; // Remove leading whitespace.
  16. for ( unsigned i=0; i<nBills; ++i )
  17. std::getline(std::cin, bills[i]);
  18.  
  19. std::cout << "The bills you entered are:\n";
  20. for (unsigned i = 0; i < nBills; ++i)
  21. std::cout << '\t' << bills[i] << '\n';
  22. }
Success #stdin #stdout 0s 3432KB
stdin
5
Capital One
Questionable Internet Porn Company
Donkey Sitters
Wildlife Conservation Fund
Mud Wrestler's Anonymous
stdout
How many bills will you enter?
Please enter the bill names.
The bills you entered are:
	Capital One
	Questionable Internet Porn Company
	Donkey Sitters
	Wildlife Conservation Fund
	Mud Wrestler's Anonymous