This assignment involves writing a C program to identify and

This assignment involves writing a C++ program to identify and count lines, words, and characters. For the purpose of this assignment, we define a \"word\" as a sequence of characters that are not whitespace characters. Words are delimited by one or more whitespace characters. A whitespace character, such as a space, tab, or newline, is any character for which the function is space() returns a value of true. The operation of your program is controlled by the command line arguments that are passed to your program. Command line arguments consist of an optional set of flags arguments (a flag argument is an argument whose first character is a dash), followed by an optional list of filenames. If no filenames are specified, the program should read from standard input. For each file specified (or, in the case of no file names specified, the standard input), the program must read the entire input and produce a count of characters, lines, and words. The output should be printed, one line per file, as follows: Lines words characters filename The numerical output (lines, words, characters) should be printed right justified in columns that are 12 characters wide. The filename should be printed left justified in the fourth column. In the case where the program in reading standard input, no filename should be printed. If the program reads multiple files, then it should also provide a line at the end of the output with a total of all of the lines, words and characters in all of the files that were processed. The totals are tagged with the label \"total\": totalLines totalWords totalCharacters total If the program is run with a flag in the form \"-findchar=x\", then the program must also count the number of times it sees the character x in each file.

Solution

# include < iostream.h >

# include < iomainp.h>

# include < conio.h >

# define MAX_ROW 5

# define MAX_COL 80

void main() {

char name [MAX_ROW] [MAX_COL], c;

int linest=1;

Cirscr();

cout<< \" === input status === \ \";

cout<<\" Enter string terminate by # : \" ;

cin.get(c);

//finding number of lines while(c != \'#\')< {

cin.get (c);

chars++;

if (c == \' \' || c == \'\ \')

word++;

if ( c == \'\ \')

lines++;

}

cout<< \"\ \"<< setw(20)<<\"particulars\"<<setw(12)<<\"details\ \";

cout<<\"..............................................\ \";

cout.setf (ios :: left, ios :: adjustfield);

cout<< \"\ \"<< setw(20) << \"no.of lines \";

cout.setf(ios::right ,ios :: adjustfield);

cout<< setw (12) << lines;

cout.set f(ios ::l eft, ios :: adjustfield);

cout<<\"\ \"<<setw(20)<<\"no.of words \';

cout.setf(ios::right,ios::adjustfield);

cout<<setw(12)<<words;

cout.setf(ios::left,ios::adjustfield);

cout<<\"\ \"<<setw(20)<<\"no.of characters \";

cout.setf(ios\"\"right,ios::adjustfield);

cout<<setw(12)<<chars;

getch();

}

 This assignment involves writing a C++ program to identify and count lines, words, and characters. For the purpose of this assignment, we define a \
 This assignment involves writing a C++ program to identify and count lines, words, and characters. For the purpose of this assignment, we define a \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site