首页 > > 详细

C++辅导 Computer Project 2调试C/C++语言


Introduction


void print_unknown_option(char const op) {
std::string es;
es = “Unknown option: “;
es += op;
es += “\n”;
write(STDERR_FILENO, es.c_str(), es.size());
}
Requirement
CSE 410 Fall 2018
Computer Project #2
Assignment Overview
This assignment focuses on system-level programming in a Linux environment. You will design and implement the
C/C++ program which is described below.
It is worth 40 points (4% of course grade) and must be completed no later than 11:59 PM on Thursday, 9/20.
Assignment Deliverables
The deliverables for this assignment are the following files:
proj02.makefile – the makefile which produces proj02
proj02.student.c – the source code file for your solution
Be sure to use the specified file names and to submit your files for grading via the CSE handin system before the
project deadline.
Assignment Specifications
Your program will display the contents of each file whose name is listed by the user.
1. The program will process each command line argument (from left to right) when the program is executed.
a) If the argument is the name of a file, the program will display the contents of that file on the standard output
stream. The appearance of the output will be modified by any “+t” and “-t” options which have been previously
processed.
b) If the argument is the string “+t”, the program will display a title before each file is displayed. The title will
consist of three lines: a line containing a series of colons, a line containing the file name, and a line containing a
series of colons. The number of colons in the first and third lines will equal the number of characters in the file
name. For example:
:::::::::::::::
proj02.makefile
:::::::::::::::
c) If the argument is the string “-t”, the program will not display a title before each file is displayed. By default, the
program will not display titles.
d) If the argument is the string “-h”, the program will display a help message on the standard error stream.
e) If the argument is an unrecognized option, the program will display an appropriate error message and a help
message on the standard error stream.
f) If the argument is the name of a file which cannot be processed, the program will display an appropriate error
message on the standard error stream.
2. The program will use the following functions to perform. input and output operations on the input files and
standard streams:
ssize_t read( int fd, void buf, size_t count );
ssize_t write( int fd, const void buf, size_t count );
The buffers associated with those functions will be 512 bytes in size.
3. The program will use the following functions to manipulate the input files:
int open( const char pathname, int flags );
int close( int fd );
The program will open the input files in “read-only” mode.
4. The program will assume that the input files contain ASCII characters.
5. The program will minimize the number of calls to function “write”.
Assignment Notes
1. As stated above, your source code file will be named “proj02.student.c”; that source code file may contain C or
C++ statements.
2. You must use “g++” to translate your source code file in the CSE Linux environment.
3. As stated above, the command-line arguments will be processed from left to right. Therefore, the “+t” and “-t”
options will only apply to file names which appear after a particular option. For example, consider the following
command line:
proj02 fileA +t fileB fileC –t fileD
The “+t” option will be applied to “fileB” and “fileC”; the “-t” option will be applied to “fileD”.
4. As stated above, the program will use “read” and “write” to perform. all input and output operations on the
input files and standard streams. However, you may use other library functions to manipulate the contents of the
buffers.
For example, it might be helpful to use library functions which process strings (such as the functions declared in
“string.h” or the C++ string class library).

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!