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

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

ElectroMyCycle

ElectroMyCycle, a manufacturer of a new electric motorcycle, has chosen you to design a new network that will let the company scale to a larger size. You learned that ElectroMyCycle’s network will support about 200 employees. The network will include a data center and a new state-of-the-art manufacturing facility. Users in the campus network will access the servers in the data center from their PCs. For online sales, ElectroMyCycle plans to have a DMZ that connects a web server, a DNS server, and an email server. ElectroMyCycle also plans to open a branch sales office in a city that is about 500 miles from ElectroMyCycle’s headquarters.   Design and document an IP addressing scheme to meet ElectroMyCycle’s needs. Specify which IP address blocks will be assigned to different modules of your network design. Document whether you will use public or private addressing for each module. Document whether you will use manual or dynamic addressing for each module. Specify where (if anywher...