Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My question is listed the below please any help this assignment , please explain about step by step in this assignment show the all of

My question is listed the below please any help this assignment , please explain about step by step in this assignment show the all of the steps

There is a skeleton code: copy_file_01.c

#include #include

int main(int argc, char* argv[]) { char ch ; FILE *source , *target;

if(argc != 3){ printf ("Usage: copy file1 file2"); exit(EXIT_FAILURE); }

source = fopen(argv[1], "r");

if (source == NULL) { printf("Press any key to exit... "); exit(EXIT_FAILURE); }

target = fopen(argv[2], "w");

if (target == NULL) { fclose(source); printf("Press any key to exit... "); exit(EXIT_FAILURE); }

while ((ch = fgetc(source)) != EOF) fputc(ch, target);

printf("File copied successfully. ");

fclose(source); fclose(target);

return 0; }

hw1 using system calls

The following program copies input file *argc[1] to output file *argc[2]. For file access the following C library functions are used:

FILE * fopen ( const char * filename, const char * mode );

int fclose ( FILE * stream ); int fgetc ( FILE * stream ); int fputc ( int character, FILE * stream ); re-write copy_file_01.c program using linux system calls replacing the functions which are listed above. 
this web page is useful: 
https://www.geeksforgeeks.org/input-output-system-calls-c-create-open-close-read-write/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 3 Lnai 8726

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448440, 978-3662448441

More Books

Students also viewed these Databases questions

Question

outline some of the current issues facing HR managers

Answered: 1 week ago