assignment, C/C++ Programming

Assignment Help:
Programming Assignment # 1

C and UNIX

 

The purpose of this assignment is to get you more familiar with Unix/Linux and those constructs of C that are not part of C++.

Write a C program (on a Unix/Linux system) that counts and displays the number of words, non-white space characters, and/or lines in a text file. The name of the input file is to be provided to the program as a command line argument. In addition, the program takes option flags to determine what actions to take. The command format is as follows:

                        command    [-clw]    inputfile

where the presence of a flag indicates the following actions:


c:  display the number of characters in inputfile.


l:   display the number of lines in inputfile. 


w: display the number of words in inputfile.

Flags can be specified in any order.  If no flags are specifyed, the command will by default display the number of characters, words, and lines. For any other format, the program should generate an appropriate error message.   Similarly, if the input file can  not be read the program should generate an appropriate error message.

For this project, I highly recommend that you use one of the common Unix editors: vi, emacs, or Pico.  Check out these references for the vi editor and emacs and pico

Be sure to document your program. Documentation should include: (1) The name of the author of the program (your name) and the date it was written, (2) a concise description of what the program does, (3) a clear description of its limitations if it does not meet all specifications, and (4) comments of critical code and data declarations. The same should also be done for each function written in the program. I will not grade any program that does not include the name of its author or a description of what it does.

Related Discussions:- assignment

Oop, what is oop?

what is oop?

Decodethecode, 6999066263304447777077766622337778 -----> message sent by th...

6999066263304447777077766622337778 -----> message sent by the first smuggler. my name is robert---------> message decoded by the second smuggler. Where ‘0’ denotes the "space". Ex

Accounts, Write a program to process bank accounts. Create a base class na...

Write a program to process bank accounts. Create a base class named Account and two derived classes named Savings and Checking. In the base class, use an int AccountNum and a dou

C program, Write a ‘C’ program to accept any 3 digit integer number from th...

Write a ‘C’ program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

Algorithm, Sine function computation

Sine function computation

I want packet capture analysis, I want Packet capture analysis Project D...

I want Packet capture analysis Project Description: Need assistance in debugging some packet capture Skills required is C Programming

What is a newline escape sequence, What is a newline escape sequence? -...

What is a newline escape sequence? - A newline escape sequence is signified by the \n character. - It is used to insert a new line whereas displaying the output data. - T

write a scheme procedure to evaluate expression, (a) Write a Scheme proced...

(a) Write a Scheme procedure to evaluate the expression: 7/6+2*5+(3*2+6*7)*4. (b) Write a Scheme procedure to evaluate the expression: 2*(-1+(-3+4*2-7)*3/(3*2)).

Padovan string, find the occurence of zy in the final string

find the occurence of zy in the final string

diana

9/12/2012 12:55:12 AM

Programming Assignment # 1

C and UNIX



The purpose of this assignment is to get you more familiar with Unix/Linux and those constructs of C that are not part of C++.

Write a C program (on a Unix/Linux system) that counts and displays the number of words, non-white space characters, and/or lines in a text file. The name of the input file is to be provided to the program as a command line argument. In addition, the program takes option flags to determine what actions to take. The command format is as follows:

command [-clw] inputfile

where the presence of a flag indicates the following actions:


c: display the number of characters in inputfile.


l: display the number of lines in inputfile.


w: display the number of words in inputfile.

Solution:

#include
#include
#include
#define MAX_ROW 5
#define MAX_COL 80


void main(){
char name[MAX_ROW][MAX_COL],c;
int lines=1; //bcoz. first line will be left to count.int words=1; //bcoz. first word will be left to count.int chars=1; //bcoz. first char will be left to count.
clrscr();
cout<<"===Input Status===\n";
cout<<"Enter string termanate by # : ";
cin.get(c);

//Finding no. of lineswhile(c != '#'){
cin.get(c);
chars++;
if(c==' ' || c=='\n')
words++;
if(c=='\n')
lines++;
}

cout<<"\n"< cout<<"-------------------------------------\n";

cout.setf(ios::left,ios::adjustfield);
cout<<"\n"< cout.setf(ios::right,ios::adjustfield);
cout<
cout.setf(ios::left,ios::adjustfield);
cout<<"\n"< cout.setf(ios::right,ios::adjustfield);
cout<
cout.setf(ios::left,ios::adjustfield);
cout<<"\n"< cout.setf(ios::right,ios::adjustfield);
cout<
getch();

}

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd