fork download
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char thisRecord[4][256];
  9.  
  10. while( cin.peek() != EOF )
  11. {
  12. cout << "In loop!" << endl;
  13. cin.getline( thisRecord[0], 5, '\n' );
  14. cin.getline( thisRecord[1], 20, '\n' );
  15. cin.getline( thisRecord[2], 9, '\n' );
  16. cin.getline( thisRecord[3], 9, '\n' );
  17. cin.getline( thisRecord[4], 9, '\n' );
  18.  
  19. // Show stock number
  20. cout.setf( ios::right );
  21. cout.width( 5 );
  22. cout << thisRecord[0];
  23.  
  24. // Show item description
  25. cout.width( 20 );
  26. cout.unsetf( ios::right );
  27. cout.setf( ios::left );
  28. cout << thisRecord[1];
  29.  
  30. // Show item cost
  31. cout.width( 9 );
  32. cout.setf( ios::right );
  33. cout << thisRecord[2];
  34.  
  35. // Show item price
  36. cout.width( 9 );
  37. cout.setf( ios::right );
  38. cout << thisRecord[3];
  39.  
  40. // Show item quantity
  41. cout.width( 9 );
  42. cout.setf( ios::right );
  43. cout << thisRecord[4] << "\n";
  44. }
  45.  
  46. system( "pause" );
  47. }
Success #stdin #stdout 0.02s 5312KB
stdin
    1 Item one                   11       12       13
    2 Item two                   12       13       14
    3 Item three                 13       14       15
stdout
In loop!