/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
#define ENDFILE "CTRL:-D" //Control-z for Windows & control-D for Unix / Linux
int main()
{
const char NWLN = '\n';
char next;
int charCount = 0 , lineCount = 0;
cout << "Enter a line or press " << ENDFILE << ": ";
cin.get(next);
while (!cin.eof())
{
charCount = 0;
while (next != NWLN)
{
cout.put(next);
charCount++;
cin.get(next);
}
cout.put(NWLN);
lineCount++;
cout << "Number of characters in a line " << lineCount << " is " << charCount << endl;
cout << "Enter a line or press " << ENDFILE << ": ";
cin.get(next);
}
cout << endl << endl << "Number of lines processed is " << lineCount << endl;
return 0;
}