Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My question is listed the below please any help this assignment ; There is a skeleton code: copy_file_01.c #include #include int main(int argc, char* argv[])

My question is listed the below please any help this assignment ;

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions