Skip to main content

1. Write the following functions, and then write a program that tests them. Your code should use C’s binary file random access functions to perform the required tasks. A sample binary file of random integers is available to you (lab10BinFile.dat), and a corresponding text file is provided so that you will be able to check your work.

Note: The functions should assume that all file ptrs point to files that are already open in the appropriate mode (input and/or output) for the function’s task.

a. A function that prints all items from a binary file of integers. Use the following prototype:

void print_bin_file(FILE *fileptr);

b. A function that returns the number of integers in a binary file of integers. Use file positioning functions, and do not read any of the integers. The function should take a pointer to the file as its argument. Use the following prototype:

int count_elements (FILE *fptr);

c. A function that returns the last integer in a binary file of integers. Use no more than one read statement, which should read only the integer in question. The function should take a pointer to the file as its argument. Use the following prototype:

int get_last(FILE *fptr);

d. A function that returns the nth integer in a binary file of integers. In main, prompt the user to enter n, and ensure that n is between 1 and the number of integers in the file before calling the function.

int get_nth(FILE *fptr, int n);

e. A function that copies one binary file of integers to a second file. The function should take pointers to the source and destination files as its arguments.

 

void copy_file(FILE *source_ptr, FILE *target_ptr);



Comments

Popular posts from this blog

1. Good time management for project managers includes initiating contact with key stakeholders only when there is a valid issue to deal with. -True -False

1. Good time management for project managers includes initiating contact with key stakeholders only when there is a valid issue to deal with. -True -False Click here for more on this paper ……. Click here to have a similar A+ quality paper done for you by one of our writers within the set deadline at a discounted 2. A project manager should identify a problem in terms of its alternate solutions so that team members can more easily reach a decision on how to solve the problem. -True -False 3. Networks are mutually beneficial alliances that are generally Click here for more on this paper ……. Click here to have a similar A+ quality paper done for you by one of our writers within the set deadline at a discounted governed by the law of: a Supply-demand b Brooks’s law c Reciprocity d A squeaky wheel e Risk-reward Click here for more on this paper ……. Click here to have a similar A+ quality paper done for you by one of our writers within the set deadline at a discounted 4...

How did life in the British colonies contribute to creating a unique American identity?

How did life in the British colonies contribute to creating a unique American identity? How do you see that identity manifested in modern American society? 200 to 300 words Click here for more on this paper ……. Click here to have a similar A+ quality paper done for you by one of our writers within the set deadline at a discounted Assignment status :  Solved by our Writing Team at EssayCabinet.com. MAKE YOUR ORDER

Netanel (1996) talks about the NIEP theory approach to copyright and the democratic paradigm. Explain the difference between these in your own words. Lessig (2008) talks about read-only (RO) and read/write (RW) culture. How can copyright facilitate both of these?

chapter one Introduction A ‘‘Largely Ignored Paradox’’ The u.s. supreme court has famously labeled copyright ‘‘the engine of free expression.’’1 Copyright law, the Court tells us, provides a vital economic incentive for the creation and distribution of much of the literature, commentary, music, art, and film that makes up our public discourse. Yet copyright also burdens speech. We often copy or build upon another’s words, images, or music to convey our own ideas effectively. We cannot do that if a copyright holder withholds permission or insists upon a license fee that is beyond our means. And copyright does not extend merely to literal copying. It can also prevent parodying, remolding, critically dissecting, or incorporating portions of existing expression into a new, independently created work. Consider The Wind Done Gone, a recent, best-selling novel by African American writer Alice Randall. Randall’s novel revisits the setting and characters of Margaret Mitchell’s classic Civil War...