
Untitled
By: a guest on
May 22nd, 2012 | syntax:
None | size: 0.94 KB | hits: 11 | expires: Never
Program 2: Write a C program that makes systems calls to produce a program called count_file_chars. This program takes a file, file_name, and a character, c, and returns the number of occurrences of the character c in the file. Extend this program so it takes an additional argument, -u, to count the number of occurrences of c independent of its case; that is you are to determine the number of occurrences of upper case c plus the number of occurrences of lower case c.
Notes: You will call your program as follows: count_file_chars( “file_name, “c”), where file_name and c are the inputs you will supply as arguments to the call. The extended version asks you to call the program as follows:
count_file_chars(-u “file_name, “c”). In both cases, flie_name is intended to be the name of a file and c a character which is input to your program. Be sure to check for errors, such as file_name not existing, incorrect permissions, etc.