CSC161 2011S Imperative Problem Solving
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazzza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
[CSC161 2010F (Rebelsky)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
Assigned: Friday, 22 April 2011
Due: 11:00 p.m., Wednesday, 27 April 2011
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, memory allocation, and more.
Expected Time: Three to four 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: Post to Pioneer Web a tarball of your
important files (your .c files, your .h
files, your Makefile, a typescript of a sample session,
a README 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. (When sorting alphabetically,
largest
means alphabetically last
.)
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 the -w command-line argument is not given, you can use
256. (This command-line argument is intended to make it easier for you
to know how much space to allocate for the buffer you use for gets
or other string input routine.)
If srt has -lnum as a command-line
argument, it should support up to num lines. If the
-l command-line arguemnt is not given, you can use 1024.
(This command-line argument is intended to make it easier to know how
big to make your array of strigs and in other places in which you may
need to reserve space for a string.)
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.
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.
Friday, 22 April 2011 [Samuel A. Rebelsky]
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Assignments/assignment.08.html.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazzza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
[CSC161 2010F (Rebelsky)]
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 Fri Apr 22 08:12:08 2011.
The source to the document was last modified on Fri Apr 22 08:12:06 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Assignments/assignment.08.html.