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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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