Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started