Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

C Language Program File Processing Paper

C Language Program File Processing Paper

C Language Program File Processing Paper

Question Description

REMEMBER, THIS IS AN INDIVIDUAL ASSIGNMENT. YOU CANNOT WORK ON THIS WITH OTHER STUDENTS. DON’T LOOK AT ANY OTHER SOLUTIONS. IF YOU GET ANY HELP, REMEMBER TO COMMENT WHERE YOU GOT THE HELP IN YOUR CODE. WE WILL BE USING CODE COMPARISON TOOLS IN GRADING.

we are going to enhance the program we wrote for count the bits. we will create a program that counts the set bits in multiple files, and we will use all the CPU cores at our disposal to do it!

our new program, pbitcount, will take a list of files. for each of these files it will start a process to count the set bits in that file. this will allow us to count the set bits in parallel.

for example, if we run pbitcount with hi.txt and rand.dat twice, three processes will get created, and we get the following:

$ ./pbitcount hi.txt rand.dat rand.dat
2534161

the program will exit with a successful (0) exit code:

$ echo $?
0

there are two classes of errors you need to handle:

1) if the program is invoked with the wrong number of arguments, you should have an exit code of 1 and print the program name (how it was invoked) with the example usage statement:

$ ./pbitcount 
USAGE: ./pbitcount filenames
$ echo $?
1

2) if the file cannot be accessed, you should have an exit code of 2 and use the perror() function to print an error message:
$ ./bitcount hi.txt filethatdoesnotexist.txt anothermissingfile.txt
filethatdoesnotexist.txt: No such file or directory
anothermissingfile.txt: No such file or directory
$ echo $?
2

when you implement your program, you will probably use the functions, fopen(), and fgetc(), so take a look at those. you must also use fork() to create processes and pipe() to communicate between processes.

your whole program must be implemented in a single file named pbitcount.c. make sure you compile with C (do not write a C++ program!).

submission

submit your single pbitcount.c file.

scoring (rubric)

points criteria
5 everything implemented in a single file
10 compiles without warning (cc –
10 passes given test cases
10 passes grader’s test cases
5 handles case when file does not exist or cannot be accessed
5 handles case when wrong number of arguments given
15 uses fork() correctly
15 uses pipe() correctly
25 code readability and logic

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Top Grade Essays only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Top Grade Essays are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Top Grade Essays is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Top Grade Essays, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.