Due: Monday, November 6 2017, 11:59 pm

Part I: File I/O and String in C

Tasks

The purpose of this part is to let you have some experience on File I/O in the C language. You are expected to implement a word counter that is able to count the number of occurrences of every word in a text file. The basic requirements are as follows.

  1. The word counter should be case-insensitive. For example, there are two occurrences of the word,"the", in the sentence, "The events in question occurred in the early days of my association with Holmes.".
  2. The word counter should be able to ignore the punctuation. For instance, "Holmes." and "Holmes," should be counted as "Holmes".
  3. The word counter should read the filename via command line.
  4. The word counter should print out the top 20 words in terms of the word frequency in descending order.
  5. You can use your linked list of Project 5 if necessary.
  6. Use this file to test your word counter. Your output should look like
          the	17
           of	7
          and	6
          was	5
           in	4
         with	4
            a	3
      windows	3
       broken	2
        wings	2
      central	2
      portion	2
          had	2
         been	2
          but	2
           up	2
         were	2
        these	1
      blocked	1
       wooden	1
    

Part II: Functions and File I/O in Selected Languages

For the first two tasks of this part, develop a wiki page for each of your languages that shows examples of file I/O and function definitions. Focus on the semantics of function declarations, how function arguments are defined and used, and how functions are treated as a data type.

Tasks

  1. For each of your languages, create some example programs that demonstrate reading and writing to both the terminal and to a file. Some things to consider in your examples and write-up include the following.

    • Does your language have built-in support for I/O, or is it part of a set of standard libraries?
    • Does your language support different types of files, such as binary v. text files?
    • Can the user input information into the program interactively?
    • What is the relationship between files and strings? Demonstrate similarities and differences in the way the programming language handles them.
  2. For each of your languages, create some examples of functions. Explore the variations in the way functions and their parameters are defined.

    Issues to consider include the following.

    • How do you define the return type of a function? Must all functions have a return value or type?
    • Can you overload functions in your language? If so, what are the rules for differentiating overloaded functions?
    • Can you create functions with an unknown number of arguments? How do you access those arguments?
    • Can you dynamically create functions? If so, how?
    • Can you override functions with a new definition?
    • What mechanism exists for publishing the existence of a function to other functions or compilable units (e.g. files)?
  3. For each of your languages, implement a word counter. The basic requirements are the same as those for the word conter in C. Use the same file to test your program.

Extensions

  1. Undertake one or more of the tasks for a third language.
  2. Write a compilable haiku on functions or file I/O in the selected languages.
  3. How does your language treat files accessed over the internet?
  4. Make your word conter more robust so that it is able to handle invalid command-line inputs and invalid files.

Submission

The submission of this project has three components:

  1. Codes: The source codes of word counter in C and the selected languages should be submitted to the fileserver, so as for the code examples for task 1 and 2 of part II. Please make the filename of your source codes meaningful.Note that the quality of your comments counts toward your grade.
  2. README: In this project, you need to submit a README file for your word counter in C and the selected languages. The README file can be a .txt file. It should be well-organized in a way that readers can easily know the usage and the outputs of your word conter in every language. In addition, the known bugs of your codes should also be indicated in the README file. Please also indicate the version of your C complier, your operationg system, and its version in the README file.
  3. Wiki write-up: The write-up of this project should have the following elements.
    • Title of the project and your name
    • The tutorials on function and file I/O in the selected languages (task 1 and 2 of part II)
    • Please include necessary code snapshots in your tutorials.

Please note that it is your responsibility to explicitly indicate the extensions you have taken. If you take the extension regarding the word counter, please indicate explicitly in the codes and README file. If you take the extensions in function anf file I/O in selected languages, please indicate explicitly in your wiki write-up or source codes and README.

© 2017 Ying Li. Page last modified: .