Write a c program that allows a user to extract some part

Assignment Help Computer Engineering
Reference no: EM132154638

Understand how to manipulate files by using system calls of open(), stat(), lseek(), write(), and create().

Instruction:

Write a C program (partcopy) that allows a user to extract some part of an existing file (fileSource) and copy it to a new file fileTarget. The user can specify the number of bytes (num1) from the beginning of filesource, how many bytes (num2) that will be extracted from it, and the new fileTarget name.

>partcopy num1 num2 filesource fileTarget

For instance, if the executable name is partcopy, extract 500 bytes from data.dat starting from the beginning of the file:

>partcopy 0 500 data.dat target.dat

For instance, if the executable name is partcopy, extract 300 bytes from data.dat starting at 50 bytes from the beginning of the file to target.dat:

>partcopy 50 300 data.dat target.dat

Note:

You need to use command line argument to acquire the num1, num2, and filetarget name.

You need to use open() system call to open an existing file. Print out the error message if the filesource does not exist byusing perror() function.

You need to check if the size of filesource againt the sizes of num1 and num2. Print out the warning message if the file size is smaller than num1+ num2. In this case, your program will just copy the content up to the end of the source file. This is the situation that the file size is too small to copy the requested size of the content.

Once the filesource is open, use lseek() system call to move the file pointer to the proper location for starting reading: num1 from the beginning of the filesource file.

Create a new file fileTarget and use read() and write() system call to copy the content from filesource to fileTarget for num2 bytes.Close files when extraction process is complete.

Reference no: EM132154638

Questions Cloud

Convert between us length and international length metrics : Write a Java GUI application to convert between US length metrics and the International length metrics.
What is the implied one year treasury rate : The 1 year treasury note is currently yielding 2.5%. What is the IMPLIED one year treasury rate one year from today?
Show a list of all the polling organizations : Show a list of all the polling organizations. Count the number of unique polling organizations.
Complete the following table for different scheduling policy : In a uniprocessor system, five processes arrive at different time. The processing time for each process is listed in following Table.
Write a c program that allows a user to extract some part : Write a C program (partcopy) that allows a user to extract some part of an existing file (fileSource) and copy it to a new file fileTarget.
Write all scripts using the shell rather than learning a new : Why not just write all scripts using the shell rather than learning a new programming language like Perl?
Create a script that prints a friendly message : Create a script that prints a friendly message. However, the script can be executed only from one terminal.
Which command can be used to rename a file or directory : What command flag can you use with cp so that it doesn't accidentally overwrite a file if it already exists (hint: look up the man page for cp)?
What do you understand by network security threat : What do you understand by network security threat? What tools and Techniques are available to make the nwtwork more secure.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Describe napoleons army march toward and eventual retreat

As you do this assignment, consider the historical data visualization developed by Charles Minard describing Napoleon's army march toward and eventual retreat from Moscow (Found in this week's presentation).

  How pipelining improves the throughput and latency of system

You will write a technical report on "The performance comparison of pipeline to non-pipelined system design". Describe how pipelining improves the throughput and latency of the system.

  Reading numbers using array

Read in five numbers. Since each number is read, show it only if it is not the duplicate of number that has already been read (that is, it is unique).

  What is the maximal length of a codeword

What is the maximal length of a codeword possible in a Huffman encoding of an alphabet of n symbols?

  Write a program that inputs this data file and prints out

Write a program that inputs this data file and prints out the total costs. Don't forget to perform necessary string processing and type conversion.

  Design a heat exchanger for the following duty

Fix a tentative geometry and perform all standard calculations and verify the adequacy of your proposed design in terms of operating parameters

  Prepare a set of nonfunctional requirements

Prepare a set of nonfunctional requirements, including operational requirements, performance requirements, security requirements, and cultural and political requirements. Much information is incomplete, but do your best.

  Atm and frame relay

ATM and Frame Relay

  Security vulnerability

What is the security vulnerability of this solution

  In privacy deborah g johnson presents arguments designed to

in privacy deborah g. johnson presents arguments designed to show that the greater capacity of computers to gather and

  Design the sr flip-flop

From the following reduced state table, derive a minimum circuit.

  Prepare an opening statement that specifies organization

The graphically depicted solution is not included in the required page length. Explain what the client can expect from your services.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd