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

Apply duty-based ethical theories to contemporary moral issues

Instructions In this research-based assessment, you will be applying a Kantian perspective to a contemporary moral issue. Current contemporary moral issues range from genetic engineering to issues related to the use of torture in wartime. For this assessment you will need to research contemporary moral issues and select one that will be the focus of your paper as you apply the Kantian perspective. Once you select your moral issue, you will need to address the following in a properly formatted research paper. · Explain what duty is according to Kant and how this view differs from other senses of duty. · Describe the relationship between a good will and duty for Kant. · Differentiate the two formulations of the Categorical Imperative. · How do these formulations apply to your selected contemporary moral issue? · Using the foundation of Kant’s moral theory explain how there is a moral duty for your selected contemporary moral issues. · Express your view as a maxim. · How feasible is it to...

A close, critical analysis of a set passage from Beowulf

Length:          500 words (excluding quotations)   Topic   Discuss in detail one of the following passages Beowulf .   Payattention to the poem’s language, and to the themes, issues,and questions the poem raises. If you choose to discuss the passage from locate the passage in relation to the poem as a whole, but focus on the extract.   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 What do you find effective or compelling or memorableabout the text?  How does the language of the poem contribute to these effects?       Marking Criteria for the Short Essay   A Short Essay receiving the highest mark is one which:   has a clear, focussed, and unified argument. (Can you say in one very simple sentence what it is that you are trying to argue in the essay?  If yo...

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...