Need it in 5-6 hrs from now..C programming..

profilejalnvemy
assignment3-final.pdf

CSE220 Programming for Computer Engineering Assignment 3

CSE220 Page 1

Assignment 3 – CSE220 – Fall 2015

1. Instructions This is an individual assignment. Please start working on it as soon as possible and ask for help if you need it. Your project solution document must be uploaded to Blackboard by the assignment deadline. Section 6 de- scribes what to submit and by when; read it now. 2. Assignment Objectives 1. Write a basic C program. 2. Define and use local variables and global constants. 3. Define and use one-dimensional arrays. 4. Define and use C-string variables and C-string arrays. 5. Use flow of control constructs such as if-statements, for-loops, and while-loops. 6. Define and use C characters and Strings 7. Parse the command line for arguments and options. 8. Use functions from stdio.h to perform I/O with stdin/stdout and text files. 9. Understand the difference between declaration and definition. 10. Understand the difference between static and nonstatic functions, variables, and constants. 11. Use the GCC C compiler to compile a C program. Use the GDB debugger to debug a program. 3. Software Requirements Your project is to write a complete C program which will read several lines of text and prints a table indicating the number of occurrences of each different word in the text. The program should include the words in the table in the same order in which they appear in the text. For example, the lines To be, or not to be: that is the question: Whether ‘t is nobler in the mind to suffer Contains the word “to” three times, “be” two times, “or” once, and so on.. By default, the program will read input from stdin and send output to stdout. The -f file option will cause the program to read the input from the text file named file and the -o file option will cause the program to write the output to the file named file. The options are, -h Display a help message and exit. -f file Read input from the text file named file. -o file Output the results to the file named file. -v Display version info and exit.

CSE220 Programming for Computer Engineering Assignment 3

CSE220 Page 2

The -h Option Your program shall output the following help message when the -h option is specified, $ ./hw3 -h Usage: hw3 [option]... Read English language text and calculate word frequencies. Options: -h Display this help message and exit. -f file Read the text from “file”. -o file Write the results to “file.\n -v Display version info and exit.\n By default, text is read from stdin and the results are sent to stdout. The -h option has higher precedence than all of the other options, meaning that if it specified along with other options, the program shall act as if -h were the only option, $ ./hw3 -f foo -o prog -h -v The above help message is displayed The -v Option Your program shall output the following version information when the -v option is specified, $ ./hw3 -v hw3: version 1.0 (2015.8.13) Faye. Navabi <[email protected]> Replace my name and email address with your name and email address, and replace the date with the date you complete your program. If -h and -v are both specified on the command line, then -h shall take precedence, i.e., display the help message and exit. $ ./hw3 -v -h The above help message is displayed The -f and -o Options If -f or -o is specified without a file name, display an error message and terminate,

CSE220 Programming for Computer Engineering Assignment 3

CSE220 Page 3

$ ./hw3 -f hw3: expecting argument following -f $ hw3 -o hw3: expecting argument following -o If the file specified with -f cannot be opened for reading (probably because it does not exist or the user made a typo), then display an error message, $ ./hw3 -f foo hw3: could not open foo If the file specified with -o cannot be opened for writing (probably because the file already exists and is read- only), then display an error message, $ ./hw3 -o /bin/date hw3: could not open /bin/date Default Input and Output By default, the program shall read the input from stdin and shall write the output to stdout, $ ./hw3 Parting is such sweet sorrow. The dog ate the cat. Goodbye. ^D The output is then displayed on the terminal window. 4.Submission When your project is complete, type make clean in your source code directory to clean your object files. the Then create a bzipped tarball named cse220-f15-hw3-lastname.tar.bz2, where lastname is your last name. $ make clean $ cd .. $ tar cvjf cse220-f15-hw3-lastname.tar.bz2 cse220-hw3 Submit this tarball to Blackboard using the assignment submission link before the deadline.