// echoWhile.cpp
// Echoes lines of text typed by the user,
// until the user types Ctrl-C to quit.
//
// Run this program and understand how it works.
// Then re-write as equivalent nested for loops.
//
// In the heading of the inner loop,
// '\n' is the newline character, used as
// end-of-line marker on Unix systems.
// (On Windows systems, the end-of-line
// marker would consist of a carriage
// return, '\r', followed by newline.)

#include <iostream>
using namespace std;

int main()
{

   cout << "Type a few lines of text, "
           << "then Ctrl-C to quit:" << endl;

   char letter;
   cin.get(letter);
   while ( true )
   {
      cout << "You tuped: ";

      while ( letter != '\n' )    // '\n' is end-of-line on Unix
      {
         cout << letter;
         cin.get(letter);
      }  // while

      cout << endl;
      cout << "Type another line (or Ctrl-C to quit):" << endl;
      cin.get(letter);
   }  // while
}  // function main