CSC161 2010F Imperative Problem Solving
[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
-
[Assignment]
[Lab]
Groupings:
[EBoards]
[Assignments]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
Assigned: Friday, 12 November 2010
Due: 11:00 p.m., Wednesday, 17 November 2010
This assignment is also available in PDF.
Summary: In this assignment, you will develop a sorting
utility similar to the standard Unix sort utility.
Purposes: To give you more experience with strings, function pointers, and more.
Expected Time: Two to three hours.
Collaboration: I encourage you to work in groups of two or three students. However, you may work on your own or in groups of up to size four. You may discuss the assignment with anyone you wish, provided you clearly document such discussions.
Submitting: Email me a tarball of your important files (your
.c files, your .h files, your Makefile,
a typescript of a sample session, and anything else you deem appropriate).
Warning: So that this assignment is a learning experience for everyone, I may spend class time publicly critiquing your work.
Write a Linux utility, srt, that sorts lines of text.
If srt is called with no command-line arguments, it should read its
input from standard input, sort the lines alphabetically, and print
the output to standard output.
If srt has -n as a command-line argument, it should
treat each line as a number.
If srt has -r as a command-line argument, it should
reverse sort
, from largest to smallest.
If srt has -u as a command-line argument, it should
unsort
the values, putting them in random order.
If srt has -wnum as a command-line argument,
it should support lines of up to num characters.
If srt has -lnum as a command-line
argument, it should support up to num lines.
If srt is called with -knum as a
command-line argument, it should break up the input at the separator character
(a space, by default) and sort using the numth column.
If srt is called with -tchar as
a command-line argument, it should use char as the separator. (This
option is pointless when used without -k.)
Anything else on the command line should be treated as a file name. No more than one file name should be permitted. If no file name appears, you should read from standard input.
If -w is not specified, you need only handle lines of up
to 256 characters.
If -l is not specified, you need to handle only up to
1024 lines.
srtsrt studentsstudents.srt students -rstudents in reverse order.srt -n gradessrt -w511 coursessrt -t, -k2 gradebook -n -r
last,first,num by grade from largest to smallest.srt -l10000 -k1 studentslast first middle, sort alphabetically by first name.srt -n students gradessrt -u studentsrandomorder.
Wednesday, 10 November 2010 [Samuel A. Rebelsky]
Thursday, 11 November 2010 [Samuel A. Rebelsky]
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2010F/Assignments/assignment.08.html.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
-
[Assignment]
[Lab]
Groupings:
[EBoards]
[Assignments]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Thu Nov 11 21:17:59 2010.
The source to the document was last modified on Thu Nov 11 21:17:57 2010.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2010F/Assignments/assignment.08.html.